Advertisement
Guest User

Untitled

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