const int led1 = 3;
const int led2 = 4;
const int led3 = A0;
const int led4 = A5;
const int button1 = 2;
const int button2 = 5;
const int button3 = A1;
const int button4 = A2;
void setup() {
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(button1, INPUT_PULLUP);
pinMode(button2, INPUT_PULLUP);
pinMode(button3, INPUT_PULLUP);
pinMode(button4, INPUT_PULLUP);
}
void loop() {
if(digitalRead(button1) == LOW){
digitalWrite(led1,HIGH);
}else{
digitalWrite(led1,LOW);
}
if(digitalRead(button2) == LOW){
digitalWrite(led2,HIGH);
}else{
digitalWrite(led2,LOW);
}
if(digitalRead(button3) == LOW){
digitalWrite(led3,HIGH);
}else{
digitalWrite(led3,LOW);
}
if(digitalRead(button4) == LOW){
digitalWrite(led4,HIGH);
}else{
digitalWrite(led4,LOW);
}
}
// const int led1 = 3;
// const int led2 = 4;
// const int led3 = A0;
// const int led4 = A5;
// const int button1 = 2; // Connect one end of the push button to pin 2
// const int button2 = 5; // Connect one end of the push button to pin 5
// const int button3 = A1; // Connect one end of the push button to pin A1
// const int button4 = A2; // Connect one end of the push button to pin A2
// bool led1State = false;
// bool led2State = false;
// bool led3State = false;
// bool led4State = false;
// void setup() {
// pinMode(led1, OUTPUT);
// pinMode(led2, OUTPUT);
// pinMode(led3, OUTPUT);
// pinMode(led4, OUTPUT);
// pinMode(button1, INPUT_PULLUP); // Activate internal pull-up resistor
// pinMode(button2, INPUT_PULLUP); // Activate internal pull-up resistor
// pinMode(button3, INPUT_PULLUP); // Activate internal pull-up resistor
// pinMode(button4, INPUT_PULLUP); // Activate internal pull-up resistor
// }
// void loop() {
// // Check if button 1 is pressed
// if (digitalRead(button1) == LOW) {
// if (!led1State) {
// digitalWrite(led1, HIGH); // Turn on LED1
// led1State = true;
// } else {
// digitalWrite(led1, LOW); // Turn off LED1
// led1State = false;
// }
// delay(200); // Debounce delay
// }
// // Check if button 2 is pressed
// if (digitalRead(button2) == LOW) {
// if (!led2State) {
// digitalWrite(led2, HIGH); // Turn on LED2
// led2State = true;
// } else {
// digitalWrite(led2, LOW); // Turn off LED2
// led2State = false;
// }
// delay(200); // Debounce delay
// }
// // Check if button 3 is pressed
// if (digitalRead(button3) == LOW) {
// if (!led3State) {
// digitalWrite(led3, HIGH); // Turn on LED3
// led3State = true;
// } else {
// digitalWrite(led3, LOW); // Turn off LED3
// led3State = false;
// }
// delay(200); // Debounce delay
// }
// // Check if button 4 is pressed
// if (digitalRead(button4) == LOW) {
// if (!led4State) {
// digitalWrite(led4, HIGH); // Turn on LED4
// led4State = true;
// } else {
// digitalWrite(led4, LOW); // Turn off LED4
// led4State = false;
// }
// delay(200); // Debounce delay
// }
// }