Hi everyone,
I am completely new to electronics and have just bought an Arduino and I am going through the tutorial lessons of Paul McWhorter. I am currently on lesson 3.
I am trying to make my red LED blink 5 times with a 500 milisecond delay and stop, the green LED blink 10 times with a 500 milisecond delay and stop and the blue LED blink 15 times with a with a 500 milisecond delay and stop, but I get an error message.
Could you please help?
[Post Edit]
I have seen many posts on this forum of similar requests, but they all used buttons and code I don't yet understand, which is why I have posted this. I'm trying to do this without a button.
[Post Edit End]
My code is here:
void setup() {
// put your setup code here, to run once:
// [Paul McWhorter YouTube Lesson 3 homework]
// I am putting all of my code in the voide setup instead of using the void loop section, so my code will only run once and stop.
pinMode (2, OUTPUT);
}
{
pinMode (4, OUTPUT);
}
{
pinMode (6, OUTPUT);
}
{
// Making my red LED blink 5 times with a 500 milisecond delay, then stop
digitalWrite (2, HIGH);
delay (500);
digitalWrite (2, LOW);
delay (500);
digitalWrite (2, HIGH);
delay (500);
digitalWrite (2, LOW);
delay (500);
digitalWrite (2, HIGH);
delay (500);
digitalWrite (2, LOW);
delay (500);
digitalWrite (2, HIGH);
delay (500);
digitalWrite (2, LOW);
delay (500);
digitalWrite (2, HIGH);
delay (500);
digitalWrite (2, LOW);
delay (500);
}
{
// Making my green LED blink 10 times with a 500 milisecond delay, then stop
digitalWrite (4, HIGH);
delay (500);
digitalWrite (4, LOW);
delay (500);
digitalWrite (4, HIGH);
delay (500);
digitalWrite (4, LOW);
delay (500);
digitalWrite (4, HIGH);
delay (500);
digitalWrite (4, LOW);
delay (500);
digitalWrite (4, HIGH);
delay (500);
digitalWrite (4, LOW);
delay (500);
digitalWrite (4, HIGH);
delay (500);
digitalWrite (4, LOW);
delay (500);
digitalWrite (4, HIGH);
delay (500);
digitalWrite (4, LOW);
delay (500);
digitalWrite (4, HIGH);
delay (500);
digitalWrite (4, LOW);
delay (500);
digitalWrite (4, HIGH);
delay (500);
digitalWrite (4, LOW);
delay (500);
digitalWrite (4, HIGH);
delay (500);
digitalWrite (4, LOW);
delay (500);
digitalWrite (4, HIGH);
delay (500);
digitalWrite (4, LOW);
delay (500);
}
{
// Making my blue LED blink 15 times with a 500 milisecond delay, then stop
digitalWrite (6, HIGH);
delay (500);
digitalWrite (6, LOW);
delay (500);
digitalWrite (6, HIGH);
delay (500);
digitalWrite (6, LOW);
delay (500);
digitalWrite (6, HIGH);
delay (500);
digitalWrite (6, LOW);
delay (500);
digitalWrite (6, HIGH);
delay (500);
digitalWrite (6, LOW);
delay (500);
digitalWrite (6, HIGH);
delay (500);
digitalWrite (6, LOW);
delay (500);
digitalWrite (6, HIGH);
delay (500);
digitalWrite (6, LOW);
delay (500);
digitalWrite (6, HIGH);
delay (500);
digitalWrite (6, LOW);
delay (500);
digitalWrite (6, HIGH);
delay (500);
digitalWrite (6, LOW);
delay (500);
digitalWrite (6, HIGH);
delay (500);
digitalWrite (6, LOW);
delay (500);
digitalWrite (6, HIGH);
delay (500);
digitalWrite (6, LOW);
delay (500);
digitalWrite (6, HIGH);
delay (500);
digitalWrite (6, LOW);
delay (500);
digitalWrite (6, HIGH);
delay (500);
digitalWrite (6, LOW);
delay (500);
digitalWrite (6, HIGH);
delay (500);
digitalWrite (6, LOW);
delay (500);
digitalWrite (6, HIGH);
delay (500);
digitalWrite (6, LOW);
delay (500);
digitalWrite (6, HIGH);
delay (500);
digitalWrite (6, LOW);
delay (500);
}
void loop() {
// put your main code here, to run repeatedly:
// left empty because I don't want my program to loop
}
My error is here:
Arduino: 1.8.13 (Windows 10), Board: "Arduino Uno"
Blinking_lights_a_set_amount_of_times_project:11:1: error: expected unqualified-id before '{' token
{
^
Blinking_lights_a_set_amount_of_times_project:15:1: error: expected unqualified-id before '{' token
{
^
Blinking_lights_a_set_amount_of_times_project:19:1: error: expected unqualified-id before '{' token
{
^
Blinking_lights_a_set_amount_of_times_project:48:1: error: expected unqualified-id before '{' token
{
^
Blinking_lights_a_set_amount_of_times_project:101:1: error: expected unqualified-id before '{' token
{
^
exit status 1
expected unqualified-id before '{' token
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
I am aware of variables and integers, because I have seen lesson 4, (I haven't seen a past level 4) but it must be possible to do this without, otherwise Paul wouldn't have told me to.
Any help is most appreciated.
Thanks,
Adam