Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. const int switchPin = 2; //
  2. const int motorPin = 9; //
  3.  
  4. int switchState = 0; //
  5.  
  6.  
  7. void setup() {
  8. pinMode(motorPin, OUTPUT); //
  9. pinMode(switchPin, INPUT); //
  10.  
  11.  
  12. } void loop() {
  13.  
  14. switchState = digitalRead(switchPin); //
  15.  
  16.  
  17. if (switchState == HIGH) { //
  18.  
  19. digitalWrite(motorPin, HIGH); //
  20. } else {
  21.  
  22. digitalWrite(motorPin, LOW); //
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement