MATLAB Answers

nt
0

Simulink : Arduino serial receive 1 byte to control pin13 led ON/OFF

Asked by nt
on 7 Jul 2014
Latest activity Commented on by nt
on 27 Dec 2014
hi everyone:
Forgive my poor English :)
i first met Simulink these days.and i played all examples in it.
i want arduino can do things below in Simulink;i don't know how to setup up serial receive block.
can someone teach me a little bit :)
-------------------------------
void setup() {
pinMode(13, OUTPUT);
Serial.begin(115200);
}
void loop() {
while(Serial.available() )
if(Serial.read() == '1')
digitalWrite(13, HIGH);
if(Serial.read() == '2')
digitalWrite(13, LOW);
}

  0 Comments

Sign in to comment.

2 Answers

Answer by Sreeram
on 31 Jul 2014
 Accepted Answer

  1 Comment

Thank you Very Much :)

Sign in to comment.


Answer by Sreeram
on 31 Jul 2014

Hi nt,
The easiest way to get to what you want is to add a Serial Receive block and add a comparator or a switch case block as you seem good for your logic at the output of the block to decide and then glow and LED.
I have attached a simple model snapshot that shows how to achieve a simple case !
Hope this helps
Thanks,
Sreeram Mohan

  0 Comments

Sign in to comment.