Advertisement
Guest User

Untitled

a guest
Oct 4th, 2015
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. void setup ()
  2. {
  3. pinMode(0,OUTPUT); //IB1
  4. pinMode(1,OUTPUT); //IA1
  5. //// pinMode(2,OUTPUT); //IB2
  6. //// pinMode(3,OUTPUT); //IA2
  7. // pinMode(4,OUTPUT); //RGB
  8. // pinMode(5,OUTPUT); //RGB
  9. // pinMode(6,OUTPUT); //RGB
  10. // pinMode(A0,INPUT); //lMotor
  11. //// pinMode(A1,INPUT); //rMotor
  12. // Serial.begin(9600);
  13. }
  14.  
  15. void loop ()
  16. {
  17. digitalWrite(0,HIGH);
  18. delay(1000);
  19. digitalWrite(0,LOW);
  20. delay(1000);
  21.  
  22. // int lMotor = analogRead(A0);
  23. // Serial.write(lMotor);
  24. //// int lMotor = analogRead(A1);
  25. //// Serial.write(lMotor);
  26. //
  27. // if (lMotor>10)
  28. // {
  29. // digitalWrite(4,HIGH);
  30. // digitalWrite(5,HIGH);
  31. // digitalWrite(6,LOW);
  32. // }
  33. // else
  34. // {
  35. // digitalWrite(4,HIGH);
  36. // digitalWrite(5,LOW);
  37. // digitalWrite(6,HIGH);
  38. // }
  39. }
  40.  
  41. void setup ()
  42. {
  43. pinMode(0,OUTPUT);
  44. pinMode(1,OUTPUT);
  45. }
  46.  
  47. void loop ()
  48. {
  49. digitalWrite(0,HIGH);
  50. delay(1000);
  51. digitalWrite(0,LOW);
  52. delay(1000);
  53. }
  54.  
  55. void setup ()
  56. {
  57. pinMode(0,OUTPUT); //IB1
  58. pinMode(1,OUTPUT); //IA1
  59. // pinMode(2,OUTPUT); //IB2
  60. // pinMode(3,OUTPUT); //IA2
  61. pinMode(4,OUTPUT); //RGB red
  62. pinMode(5,OUTPUT); //RGB green
  63. pinMode(6,OUTPUT); //RGB blue
  64. boolean motorOn = false;
  65. }
  66.  
  67. void loop ()
  68. {
  69. digitalWrite(0,motorOn);
  70. if(motorOn) {
  71. digitalWrite(4,HIGH); // red on
  72. digitalWrite(5,LOW); // green off
  73. digitalWrite(6,LOW); // blue off
  74. }
  75. digitalWrite(4,LOW); // red off
  76. digitalWrite(5,HIGH); // green on
  77. digitalWrite(6,LOW); // blue off
  78. }
  79. delay(1000); // wait
  80. motorOn = !motorOn; // toggle the status of the motor.
  81. }
  82.  
  83. void setup ()
  84. {
  85. pinMode(0,OUTPUT); //IB1
  86. pinMode(1,OUTPUT); //IA1
  87. // pinMode(2,OUTPUT); //IB2
  88. // pinMode(3,OUTPUT); //IA2
  89. pinMode(4,OUTPUT); //RGB red
  90. pinMode(5,OUTPUT); //RGB green
  91. pinMode(6,OUTPUT); //RGB blue
  92. boolean motorOn = false;
  93. }
  94.  
  95. void loop ()
  96. {
  97. motorOn = false;
  98. digitalWrite(0,motorOn);
  99. updateLEDs(); // update the LED status
  100. delay(1000); // wait
  101. motorOn = true; // toggle the status of the motor.
  102. digitalWrite(0,motorOn);
  103. updateLEDs(); // update the LED status
  104. delay(750); // wait a different time
  105. }
  106.  
  107. void updateLEDs(){
  108. // This routine updates the LEDs based on status of motorOn.
  109. if(motorOn) {
  110. digitalWrite(4,HIGH); // red on
  111. digitalWrite(5,LOW); // green off
  112. digitalWrite(6,LOW); // blue off
  113. }
  114. digitalWrite(4,LOW); // red off
  115. digitalWrite(5,HIGH); // green on
  116. digitalWrite(6,LOW); // blue off
  117. }
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement