Hi all,
I hope you don't mind a few questions.
I got the Arduino UNO a week ago and am enjoying it so far but have come up against a couple of problems I cant figure out.
Below is the code I have for the setup of a basic traffic light sequence that I started from a tutorial. I modified it to add the walk/dont walk lights and converted the sequence to match UK traffic lights.
.(Original tutorial Tutorial here)
The sequence works fine and looks good.
The problem is the error shown in the code below when following instructions to add a button:
void setup(){
const int red = 13;
const int yellow = 12;
const int green = 11;
const int walk = 10;
const int nowalk = 9;
const int button = 2; // switch is on pin 2
int buttonValue = 0; // switch defaults to 0 or LOW
pinMode(button,INPUT);
buttonValue = (digitalRead, button);
digitalWrite(green,HIGH);
digitalWrite(nowalk, HIGH);
pinMode(red,OUTPUT);
pinMode(yellow,OUTPUT);
pinMode(green,OUTPUT);
pinMode(walk, OUTPUT);
pinMode(nowalk, OUTPUT);
}
void loop(){
if(buttonValue = HIGH) //buttonValue was not declared in this scope. <--------
changeLights();
delay(1000);
How do i fix this error/what have i done wrong? (hours of googling and tinkering and I'm stumped.
Next issue:
I have the button wired up as shown in the tutorial posted above but if i connect the trigger wire the sequence triggers and runs indefinitely until I disconnect the wire. Could this be because of the error in the code?
I have confirmed the button is push to make a connection via a continuity test, the connection is made when pressed and broken when released.
When the trigger wire is disconnected, The lights will not run continuously but will seemingly run randomly. I can also trigger the sequence by just touching the wire (as it the board is reacting to my own electrical field?)
Does the IDE interact with the UNO while connected to the Laptop in a way that could trigger the lights?
Any help would be highly appreciated.
Thanks
Dave