Hello there,
i am currently doing my work for my school exams.
I want to build an sensor that makes an sound when the ball rolls over the gate.
I replaced the sensors with buttons. My teacher said it does the same.
The first button works but the second is not working.
I tried to add something to the programm so that it says here is another button.
Here is the code and the error message. :
code:
int LEDblau=6;
int taster=7;
int tasterstatus=0;
int links=8;
int rechts=9;
int taster2=4;
void setup()
{
pinMode(LEDblau, OUTPUT);
pinMode(taster, INPUT);
pinMode(links, INPUT);
pinMode(rechts, INPUT);
pinMode(taster2, INPUT);
Serial.begin(9600);
}
void loop()
{
tasterstatus=digitalRead(links);
if (tasterstatus == HIGH)
{
digitalWrite(LEDblau, HIGH);
delay (100);
digitalWrite(LEDblau, LOW);
delay (100);
digitalWrite(LEDblau, LOW);
digitalWrite(LEDblau, HIGH);
delay (100);
digitalWrite(LEDblau, LOW);
}
else
{
digitalWrite(LEDblau, LOW);
}
}
void loop()
{
tasterstatus=digitalRead(rechts);
if (tasterstatuss == HIGH)
else
}
error message:
H:\Eigene Dokumente\Arduino\sketch_mar14a\sketch_mar14a.ino: In function 'void loop()':
sketch_mar14a:37: error: redefinition of 'void loop()'
void loop()
^
H:\Eigene Dokumente\Arduino\sketch_mar14a\sketch_mar14a.ino:16:6: note: 'void loop()' previously defined here
void loop()
^
sketch_mar14a:41: error: 'tasterstatuss' was not declared in this scope
if (tasterstatuss == HIGH)
^
sketch_mar14a:43: error: expected primary-expression before 'else'
else
^
exit status 1
redefinition of 'void loop()'