Quantcast
Channel: MSP low-power microcontrollers
Viewing all articles
Browse latest Browse all 62309

Forum Post: RE: MSP 432 LED codes

$
0
0
Hi Justin, My first suggestion would be to combine everything into one big loop, that way there aren't two separate files. I think where you are running into trouble is in the if, else if, and else statements. I'd consider using case and switch statements instead. I've outlined an example of how this might look, below. The tricky part about a case and switch is that each case must be an int value, so you'd have to convert the raw serial data first. In the example I skipped that part and put in numbers instead of the 'on1'/'off1' string. I'd suggest first trying this with simple int values before you switch to the char implementation. void loop() { if (Serial.available() > 0) { int inByte = Serial.read(); switch (inByte) { case '1': //on1 digitalWrite(40, HIGH); break; case '2': //off1 digitalWrite(40, LOW); break; case '3': //on2 digitalWrite(39, HIGH); break; case '4': //off2 digitalWrite(39, LOW); break; } } } Thanks, Mitchell

Viewing all articles
Browse latest Browse all 62309

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>