Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. int motorPin=3;
  2. void setup() {
  3. pinMode(motorPin, OUTPUT);
  4. Serial.begin (9600);
  5. while (! Serial);
  6. Serial.println("Speed 0 to 10");
  7.  
  8. }
  9.  
  10. void loop()
  11. {
  12.  
  13. if (Serial.available ())
  14. {
  15. int speed= Serial.parseInt();
  16. if (speed >= 0 && speed <= 250)
  17. {
  18. analogWrite(motorPin, speed);
  19. }
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement