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: sending values fro matlab to arduino
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Rak

Posts: 35
Registered: 3/30/12
sending values fro matlab to arduino
Posted: Jul 18, 2013 6:46 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....



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.