Advertisement
jmyean

Setting Up a Continuous Motor Circuit

Apr 25th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  /*
  2.   *  Jung Min Yean
  3.   *  Learning How to Use a Continuous Motor
  4.   *  04/23/2019
  5.   */
  6.  
  7. const int motorPin = 9;
  8.  
  9. void setup()
  10. {
  11.   pinMode(motorPin, OUTPUT);
  12.   Serial.begin(9600);
  13. }
  14.  
  15. void loop()
  16. {
  17. for (int i = 0; i<255; i++)
  18. {
  19.   analogWrite(motorPin,i);
  20.   delay(10);
  21. }
  22. delay(100);
  23.  
  24. for (int i = 255; i>0; i--)
  25. {
  26.   analogWrite(motorPin,i);
  27.   delay(10);
  28. }
  29. delay(100);
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement