Serial. Your browser does not support the Web Arduino introduces a new board based on the. (I know I could probably code the colours far more efficiently but i'm only just beginning so go easy on me ) int rPin = 6 This is intended for repetitive tasks, like reading from a sensor or uploading some information or blinking lights. The code for the 'while' loop waiting in serial input is lines 28 to 70 The loop () function is where you do the work. This is where most of you code goes, reading sensors sending output etc. Instead of doing 'If the button is pressed then continue' you need to do 'while the button is not pressed do nothing'. I've made it an infinite loop while (1) so that it would never exit. Once setup() is finished, Arduino calls the loop() method over and over again. The construct you are looking for is called while. It enters the loop and it runs once, the problem it doesn't run more than once. That is why they added the do-while () loop. I have the code working to constantly cycle the colours on it's own, but when I paste it into a 'while' function that is waiting for serial input (Serial.available() = 0) it runs once and then waits for input but doesn't cycle again. If the while () condition is false when you try to enter the loop, it will not run. I have the bulk of the code working, the only thing stumping me is how to get the LED to cycle through the spectrum whilst waiting on a serial input. It basically just counts down milliseconds inside a while loop and times it with micros (). It's basically an RGB LED that will change colour to match an input on the serial monitor. The delay function doesnt do anything special. I'm currently trying to do my first simple project written & designed by myself from the ground up.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |