Hey, this is my first time on the forum, and I have a couple of questions.
I'm very new to arduino, as well as coding. I got an Arduino Uno SMD for Christmas, as well as an accompanying book. I Have been following the exercises in the book to help start me off.
In this exercise, I am using serial communication to turn an LED on and off by pressing either 1 or 2. This worked fine, and I decided to add in a third command, '3'. This would repeatedly blink the LED on and off. The code compiles and uploads fine, but when I enter 3, the LED blinks on for 100ms, then off and does not loop. I've spent a couple of hours tinkering around but cannot make it work. I came here for some suggestions.
Additionally, I tried to rename the commands for turning the LED on and off, 1 and 2 respectively, "on" and "off", so that when I type on or off in the serial monitor, they will correctly carry out their actions.
When I enter "on" in the serial monitor I get:
Unknown Command: 111
Unknown Command: 110
When I enter "off" I get:
Unknown Command: 111
Unknown Command: 102
Unknown Command: 102
I believe these numbers to be the ASCII for each individual letter, but I can't figure out how to make the code understand it as a single command.
Any help would be appreciated.
I did run you program, it was not working because of command=='on' . I change the code for command=='o' . I modify your code, when you command 3 , it is blinking 3 time... and I notice a loop() within a loop() ... bad programming... anyway I re-write your code and I hope you will understand it.
Thanks for the rewrite.
Again, I'm very new to all of this so I'm wondering if I could get some explanations.
Earlier, when you tell the code what to do when you press 3, you call on blink3time
Can you define what "blink3time" does just by writing a separate entry such as this
void blink3time() is call a function. So I name it that way, if you need to blink more time, you just going to the function and change the for() function. The for(int i=0;i<4;i++) is integer i = 0 and start at 0, i++ is i=i+1 i<4 is count if i is lower that 4.
If you want to learn more, in your IDE, click "help" and select "Reference" , most of the key words are there and click on them to find an explanations of the function/statement.