Advertisement
icstation

Bluetooth Multi-Function Car Kit Intelligent Car for Arduino

Dec 16th, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. the code and the Installation manual for the Bluetooth Multi-Function Car Kit Intelligent Car for Arduino
  2. for more details:
  3. http://www.icstation.com/product_info.php?products_id=2529
  4.  
  5. //There are more information aboat this code in Page 9 of "Instruction manual-English.pdf"
  6. int pinI1=8;//define IN1
  7. int pinI2=9;//define IN2
  8. int speedpin=11;//define EA(PWM)
  9. int pinI3=6;//define IN3
  10. int pinI4=7;//define IN4
  11. int speedpin1=10;//define EB(PWM)
  12. void setup()
  13. {
  14. pinMode(pinI1,OUTPUT);
  15. pinMode(pinI2,OUTPUT);
  16. pinMode(speedpin,OUTPUT);
  17. pinMode(pinI3,OUTPUT);
  18. pinMode(pinI4,OUTPUT);
  19. pinMode(speedpin1,OUTPUT);
  20. }
  21. void loop()
  22. {
  23. //go straight
  24. analogWrite(speedpin,100);//input analog value to set speed
  25. analogWrite(speedpin1,100);
  26. digitalWrite(pinI4,LOW);//right motor move in anticlockwise
  27. digitalWrite(pinI3,HIGH);
  28. digitalWrite(pinI1,LOW);//left motor move in clockwise
  29. digitalWrite(pinI2,HIGH);
  30. delay(2000);
  31. //go back
  32. analogWrite(speedpin,100);//input analog value to set speed
  33. analogWrite(speedpin1,100);
  34. digitalWrite(pinI4,HIGH);//right motor move in clockwise
  35. digitalWrite(pinI3,LOW);
  36. digitalWrite(pinI1,HIGH);//left motor move in anticlockwise
  37. digitalWrite(pinI2,LOW);
  38. delay(2000);
  39. //turn left
  40. analogWrite(speedpin,60);//input analog value to set speed
  41. analogWrite(speedpin1,60);
  42. digitalWrite(pinI4,LOW);//right motor in anticlockwise
  43. digitalWrite(pinI3,HIGH);
  44. digitalWrite(pinI1,HIGH);//left motor in anticlockwise
  45. digitalWrite(pinI2,LOW);
  46. delay(2000);
  47. //turn right
  48. analogWrite(speedpin,60);//input analog value to set speed
  49. analogWrite(speedpin1,60);
  50. digitalWrite(pinI4,HIGH);//right motor in clockwise
  51. digitalWrite(pinI3,LOW);
  52. digitalWrite(pinI1,LOW);//left motor in anticlockwise
  53. digitalWrite(pinI2,HIGH);
  54. delay(2000);
  55. //stop
  56. digitalWrite(pinI4,HIGH);//right motor stop
  57. digitalWrite(pinI3,HIGH);
  58. digitalWrite(pinI1,HIGH);//left motor stop
  59. digitalWrite(pinI2,HIGH);
  60. delay(2000);
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement