/*Electric Building Unit: Science: 2019*/
const int buttonOne, 2);
const int buttonTwo, 3); //redefining the names.
void setup() {
pinMode(buttonOne, INPUT);
pinMode(buttonTwo, INPUT);
pinMode(buttonThree, INPUT);
pinMode(buttonFour, INPUT); //all of these are being set to input.
}
Serial.begin //starts the serial monitor
void loop() {
if(buttonOne==HIGH&&!LOW){
Serial.print("It's button 1!"); //detecting if button 1 is high, if so, it prints in the serial.
}
else{
if(buttonTwo==HIGH&&!LOW){
Serial.print("It's button 2!"); //same as before, with button 2.
}
}
}
Does anyone know why I am getting an error and what it means?
void setup() {
pinMode(buttonOne, INPUT);
pinMode(buttonTwo, INPUT);
pinMode(buttonThree, INPUT);
pinMode(buttonFour, INPUT); //all of these are being set to input.
}
How many buttons have you defined at the start of your code? How does that compare to the amount of buttons you're trying to set as inputs here?
Serial.begin //starts the serial monitor
This line definitely needs to be fixed.
void loop() {
if(buttonOne==HIGH&&!LOW){
Serial.print("It's button 1!"); //detecting if button 1 is high, if so, it prints in the serial.
There is an example in the IDE that demonstrates how to read a button press. Have a quick look at it- there's no real reason to compare the button state to HIGH or not LOW. It is superfluous.