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

1 回表示 (過去 30 日間)
nt
nt 2014 年 7 月 7 日
コメント済み: nt 2014 年 12 月 27 日
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);
}

採用された回答

Sreeram
Sreeram 2014 年 7 月 31 日

その他の回答 (1 件)

Sreeram
Sreeram 2014 年 7 月 31 日
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

カテゴリ

Help Center および File ExchangeArduino Hardware についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by