Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int buttonPin1 = 1;
- const int buttonPin2 = 2;
- const int buttonPin3 = 3;
- const int buttonPin4 = 4;
- const int buttonPin5 = 5;
- const int buttonPin6 = 6;
- int buttonState1 = 0;
- int buttonState2 = 0;
- int buttonState3 = 0;
- int buttonState4 = 0;
- int buttonState5 = 0;
- int buttonState6 = 0;
- void setup() {
- Serial.begin(9600);
- pinMode(buttonPin1, INPUT_PULLUP);
- pinMode(buttonPin2, INPUT_PULLUP);
- pinMode(buttonPin3, INPUT_PULLUP);
- pinMode(buttonPin4, INPUT_PULLUP);
- pinMode(buttonPin5, INPUT_PULLUP);
- pinMode(buttonPin6, INPUT_PULLUP);
- }
- void loop() {
- buttonState1 = digitalRead(buttonPin1);
- buttonState2 = digitalRead(buttonPin2);
- buttonState3 = digitalRead(buttonPin3);
- buttonState4 = digitalRead(buttonPin4);
- buttonState5 = digitalRead(buttonPin5);
- buttonState6 = digitalRead(buttonPin6);
- if (buttonState1 == HIGH) {
- Serial.println("button1 press");
- }
- if (buttonState2 == HIGH){
- Serial.println("button2 press");
- }
- else if (buttonState3 == HIGH){
- Serial.println("button3 press");
- }
- else if (buttonState4 == HIGH){
- Serial.println("button4 press");
- }
- else if (buttonState5 == HIGH){
- Serial.println("button5 press");
- }
- else if (buttonState6 == HIGH){
- Serial.println("button6 press");
- }
- else{
- }
- }
Add Comment
Please, Sign In to add comment