Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. const int buttonPin = 7; // the number of the pushbutton pin
  2. const int ledPin = 6; // the number of the LED pin
  3.  
  4. // variables will change:
  5. int buttonState = 0; // variable for reading the pushbutton status
  6.  
  7. void setup() {
  8. Serial.begin(9600);
  9. // initialize the LED pin as an output:
  10. pinMode(ledPin, OUTPUT);
  11. // initialize the pushbutton pin as an input:
  12. pinMode(buttonPin, INPUT);
  13. }
  14.  
  15. void loop() {
  16. // read the state of the pushbutton value:
  17. buttonState = digitalRead(buttonPin);
  18.  
  19. // check if the pushbutton is pressed. If it is, the buttonState is HIGH:
  20. if (buttonState == HIGH) {
  21. // turn LED on:
  22. digitalWrite(ledPin, HIGH);
  23. Serial.println("gomb");
  24. } else {
  25. // turn LED off:
  26. digitalWrite(ledPin, LOW);
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement