Grimmreefer

Paint'nPain Arduino Leonardo Buzzer

Jan 24th, 2023
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | Software | 0 0
  1.    
  2. #include "Keyboard.h"
  3. const int Button_3 = 2;    
  4. const int Button_4 = 9;    
  5.  
  6. int buttonState_3 = 0;
  7. int lastbuttonState_3 = 0;
  8.  
  9. int buttonState_4 = 0;
  10. int lastbuttonState_4 = 0;
  11.  
  12.  
  13. void setup(){
  14.  
  15.   pinMode(Button_3, INPUT_PULLUP);
  16.   pinMode(Button_4, INPUT_PULLUP);
  17.  
  18.  
  19. }
  20.  
  21. void loop(){  
  22.  
  23.  
  24.   buttonState_3 = digitalRead(Button_3);
  25.  
  26.   if(buttonState_3 == HIGH){
  27.     Serial.print("3");
  28.     //Keyboard.print("W");
  29.     lastbuttonState_3 = buttonState_3;
  30.   }
  31.  
  32.  
  33.   buttonState_4 = digitalRead(Button_4);
  34.  
  35.   if(buttonState_4 == HIGH){
  36.     Serial.print("4");
  37.     //Keyboard.print("A");
  38.     lastbuttonState_4 = buttonState_4;
  39.   }
  40. }
Add Comment
Please, Sign In to add comment