I have copied what it says in the book ive got with the arduino but... It doesnt seem to work, first it was something about ' void loop' not including something so I tried to remove some 'void loops' and now it looks like this:
int switchstate = 0;
void Setup () {
pinMode (3,OUTPUT);
pinMode (4,OUTPUT);
pinMode (5,OUTPUT);
pinMode (2,INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
switchState = digitalRead (2) ;
if (switchState == LOW) {
digitalWrite(3, HIGH); //grön lampa
digitalWrite(4, LOW); //röd lampa
digitalWrite(5, LOW); //röd lampa
else {
digitalWrite (3, LOW);
digitalWrite (4, LOW);
digitalWrite (5, HIGH);
delay (250);
digitalWrite (4, HIGH);
digitalWrite (5, LOW);
delay (250);
}
And now it says the 'switchState' isnt declared in the scope and highlighting the "switchState = digitalRead (2) M ;"
Can you think of anything that is wrong and if so, what and why? Arduino is really entertaining even thou i ran into issues already on the first project.
I want to learn more about arduino so i can control my led stripes in my van. Do you guys have any idea how an easy sketch may look like? If I wanted to change the colours by voice control. Say red and the light is red.
Hope I have made my self understood. Best regards