Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Matlab to Arduino
Replies: 1   Last Post: Jul 10, 2013 5:26 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Rak

Posts: 35
Registered: 3/30/12
Re: Matlab to Arduino
Posted: Jul 10, 2013 5:26 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I m trying it with asimple example of blinking 2 leds.
From Matlab im giving values say 1, 2,1,2.Now im writing just 1 and 2.

fopen (s)
for i = 1:2
fwrite(s, i, 'uint8');
end
fclose(s);

In arduino, these values should reach. And i have written code in such a way that
,if 1 comes then led1 blinks, if 2 comes led 2 blinks and soon.

Arduino code:
void loop()
{
while(Serial.available() > 0){

Data=Serial.read();

if(Data==1){
digitalWrite(ledPin1,HIGH); // turn light on
digitalWrite(ledPin2,LOW);
delay(1000);
digitalWrite(ledPin2,LOW);
digitalWrite(ledPin1,LOW);
}
if(Data==2){
digitalWrite(ledPin2,HIGH);
digitalWrite(ledPin1,LOW);
delay(1000);
digitalWrite(ledPin2,LOW);
digitalWrite(ledPin1,LOW);
}


This doesnt work..!!! Please help....


Date Subject Author
7/10/13
Read Matlab to Arduino
Rak
7/10/13
Read Re: Matlab to Arduino
Rak

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.