BorderlineJunkie

PiCar_C__Motor-test

Apr 12th, 2021 (edited)
778
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     PiCar_C ZeroW
  2.  
  3. By Markus Messerschmidt; 10.04.2021
  4. Ein altes Rc Auto mit ehmals 27mhz das zum Antrieb und Lenkung 2 DC Motoren verwendet, 4Led´s.
  5. Raspberry Pi Zero W mit Raspian, Arduino Nano, Raspi Cam, L293d MotorController,
  6. Ubec auf 5.1V für -Pi -Nano -L293d,
  7. Akku = Lipo 2s 7,4 Volt
  8.  
  9. Oranges Kabel is HighVoltage(HV) [AkkuSpannung]
  10. Rotes   Kabel ist 5V Logikstrom
  11. Schwarz = GND
  12.                      
  13. ssh pi .XX {XX}
  14.  
  15. --------------------------  L293d       -----------------------------------
  16. Motor1  __Antrieb__
  17.  
  18. Ena  = grün
  19. In1  = gelb
  20. In2  = blau
  21.  
  22.  
  23. Motor2  __Lenken__
  24.  
  25. Enb  = hellblau
  26. In3  = grau
  27. In4  = türkis
  28.  
  29.  
  30. ............................  Arduino_Nano   .............................
  31.   ---Zu L293d
  32. D12 hellblau    Enb Lenken
  33. D11 türkis      In4
  34. D10 grau        In3...........
  35. D09 blau        In2
  36. D08 gelb        In1
  37. D07 grün        Ena Motor
  38.  
  39.   ---zu Zero
  40. D06 gelb    Data4   19
  41. D05 türkis Data3   13
  42. D04 blau    Data2   6
  43. D03 grau    Data1   5
  44.  
  45.  
  46. ::::::::::::::::::::::::::::    Pi Zero W     ::::::::::::::::::::::::
  47.   ---von Nano
  48. Gpio     5 grau
  49. Gpio     6 blau
  50. Gpio    13 türkis
  51. Gpio    19 gelb
  52.  
  53.   ---von L293d
  54. Gpio    16 Ena  Motor
  55. Gpio    20 In1
  56. Gpio    21 In2
  57. Gpio    23 In3
  58. Gpio    24 In4
  59. Gpio    25 Enb  Lenken
  60.  
  61. ------------------------------------------------------------------------------
  62.  
  63.   ---Led´s
  64.         Front [2x weiß]
  65. Gpio
  66.  
  67.         Heck  [je 1x weiß] {Blinken}
  68. Gpio
  69. Gpio
  70.  
  71.  
  72. *******************************************************************************
  73. *******************************************************************************
  74.  
  75.    
  76. const int EnableL = 12;
  77. const int HighL = 11;       // Lenk motor
  78. const int LowL =10;
  79.  
  80. const int EnableR = 7;
  81. const int HighR = 8;       // Antrieb motor
  82. const int LowR =9;
  83.  
  84. void setup() {
  85.  
  86. pinMode(EnableL, OUTPUT);
  87. pinMode(HighL, OUTPUT);
  88. pinMode(LowL, OUTPUT);
  89.  
  90.  
  91. pinMode(EnableR, OUTPUT);
  92. pinMode(HighR, OUTPUT);
  93. pinMode(LowR, OUTPUT);
  94.  
  95. }
  96.  
  97. void Forward()
  98. {
  99.   digitalWrite(HighR, LOW);
  100.   digitalWrite(LowR, HIGH);
  101.   analogWrite(EnableR,135);
  102.   //delay(400);
  103.   //analogWrite(EnableR,110);
  104.  
  105.  
  106. }
  107.  
  108. void Backward()
  109. {
  110.  
  111.   digitalWrite(HighR, HIGH);
  112.   digitalWrite(LowR, LOW);
  113.   analogWrite(EnableR,100);
  114.  
  115. }
  116.  
  117.  
  118. void Stop()
  119. {
  120.  
  121.   digitalWrite(HighR, LOW);
  122.   digitalWrite(LowR, LOW);
  123.   analogWrite(EnableR,0);
  124.  
  125. }
  126.  
  127.  
  128. void Left()
  129. {
  130.  
  131.   digitalWrite(HighL, HIGH);
  132.   digitalWrite(LowL, LOW);
  133.   analogWrite(EnableL,255);
  134.  
  135. }
  136.  
  137. void Right()
  138. {
  139.  
  140.   digitalWrite(HighL, LOW);
  141.   digitalWrite(LowL, HIGH);
  142.   analogWrite(EnableL,255);
  143.  
  144. }
  145.  
  146. void loop()
  147. {
  148.  Forward();
  149.  Left();
  150.  delay(3000);
  151.  Stop();
  152.  
  153. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×