I am new to Arduino and C++ and I was practicing with a traffic light project.
This is my code:
int red = 10;
int yellow = 9;
int green = 8;
void setup() {
pinMode(red,OUTPUT);
pinMode(yellow,OUTPUT);
pinMode(green,OUTPUT);
}
void loop() {
changelights();
delay (15000);
}
void changelights{
// 1st action: green off to yellow
digitalWrite(green, LOW);
digitalWrite(yellow, HIGH);
delay (3000)
// 2nd action: tellow to red
digitalWrite(yellow, LOW);
digitalWrite(red, HIGH);
//3rd action: caution light
digitalWrite(yellow, HIGH);
delay (3000)
//4th action: caution to go
digitalWrite(red,LOW);
digitalWrite(yellow, LOW);
digitalWrite(green, HIGH);
}
I tried compiling it and returned an error message that said that I did not declare my "changelights" function. What should I do to fix this?
Thank you very much
( )for the parameters after the definition ofchangelights. You need these, even if you don't provide any parameters. Though this is a pure C/C++ syntax question, thus I'm voting to close. Fixing such problems doesn't help any other people, thus I'm always helping in the comments and then vote to close.delay(3000)calls.