Some new stuff
  1. Arduino Park Control
  2. Arduino USB2serial programming the bare bone
  3. Arduino Projects Videos added
  4. Arduino Xbee projects
  5. Arduino dB Meter 
  6. Trying to get the IOIO going. 
  7. IOIO is going....bluetooth
  8. Attiny 2313 bluetooth bee RC car
  9. Compass and temperature added
  10. AVR programmer
  11. USB2Serial and Ethernet POE
  12. Arduino LPG Sensor
  13. Program the Arduino Mini 05
  14. Lipo Rider Pro in action
  15. EZ Robot Builder kit arrived 10 Nov 2012
  16. Arduino VA Meter!
  17. 05 Nov 2012 Project Sentry Gun.
  18. Attiny85 PIR Sensor 10 Dec 2012 
  19. 0-30VDC3A and 2-28VDC10A bench PSU's
  20. 19 Dec 2012 Arduino Voltmeter LCD
  21. 29 Dec 2012 Arduino Tachometer&Speedometer LCD
  22. 03 Jan 2013 Arduino AC Phase Control. 
  23. 18 Jan 2013 Arduino Distance Meter
  24. 22 Jan 2013 Arduino Digital Clock and Date
  25. 31 Jan 2013 Arduino Digital Clock and Date 8x2 LCD
  26. Feb 2013 LCD and Backpack
  27. Feb 2013 7 Segment Serial Clock Sparkfun. Distance Sensor with "newping" library
  28. Feb 2013 Lelo Remote
  29. 01/03/2013 Arduino Adafruit 7 Seg Digital Clock with RTC and backpack 
  30. Arduino Frequency Meter 26/03/2013
  31. Another RC  Car controlled by Arduino 06/04/2013
  32. My quadcopter project update 25 April 2013
  33. My Aqua Quad Copter Flying 26 April 2013enlightened
  34. Another monster RC truck;strong one! 11July2013cool
  35. X-Frame Quad Copter 31 July 2013cool
  36. Arduino GSM Sheild added.28/8/2013
  37. 1.8inch TFT screen 13/09/2013cool
  38. 04/11/2014 added PID Soldering Iron Control
  39. Added bluetooth servo control 04/11/2014
  40. ESP8266 first try.16/03/2015
  41. Arduino Uno Quadcopter 19 May 2015
  42. IOT WemosD1 Amp Meter



Arduino RC Bluetooth servo and one dc motor control. The servo for front steering and one dc motor for back wheel drive.

The original code is from Garage Lab, and I changed the code slightly to accommodate other needs.

Also, in place of the TB6612FNG motor driver board used in garage lab example, I am using the l298

Garage Lab is using two dc motors and my effort is with on dc motor.


//Use one chanel of L298
//ardubottom.h contains code necessary for the function of this sketch. 
//You must make sure that it is in the same location as this sketch
#include "ardubottom.h"
//Header necessary to connect to and control our servo.
#include <Servo.h>
//Variable Declarations
//variables representing the gearbox motors output pins, and the position of the servo.
int motA_1 = 2,motA_2 = 4,pos = 90;
int E1 = 3;
Servo lrservo;//create a servo object
//create a cur_Dir object to represent the direction of our robot
cur_Dir currentDirection;
//Function Prototypes
void MoveGearBox(RobotDirection);
void MoveServo(RobotDirection);
void setup()
//Start the USART so we can receive command from the controller

 //Set the gearbox motors control pins as outputs 
  pinMode(motA_1, OUTPUT);
  pinMode(motA_2, OUTPUT);
  pinMode(E1, OUTPUT);
 // pinMode(motB_1, OUTPUT);
 // pinMode(motB_2, OUTPUT);
  lrservo.attach(8);//Attach pin 8 to our servo object
  lrservo.write(pos);//Write the starting position to the servo object which is 90, half of 180
  currentDirection = Nowhere;  //Set the starting direction to nowhere 
void loop()
  //If there are commands available from the controller

  while(Serial.available() > 0)
  //Check if the command character matches any of the following cases
      //If it's 'F'
      case 'F'://Set the current direction of the robot to Forward
      currentDirection = Forward; 
      break;//Stop checking cases
      //If it's 'B'        
      case 'B'://Set the direction to Backwards
      currentDirection = Backwards;
      break;//Stop checking cases
      //If it's 'L'         
      case 'L'://Set the current direction to Left
      currentDirection = Left;
      break;//Stop checking cases
      //If it's 'R'        
      case 'R'://Set the current direction to Right
      currentDirection = Right;
      break; //Stop checking cases
      default://This case is evaluated if all other cases fail to match
              //in which case we set the current direction to Nowhere      
      currentDirection = Nowhere;
      break;//and finish checking all the cases
   //Then we send the current direction to the MoveGearBox function
   //And the MoveServo function where it will be evaluated and acted upon accordingly    
void MoveServo(RobotDirection dir)
  int servoSpeed = 4;
  //If the direction is Left and we have not yet hit the left bound
  if(dir == Left && pos >0)
    //then decrease the position of the servo (turn counter-clockwise)
   pos -= servoSpeed;
  //But if the direction is Right and we have not reached the right bound
  else if(dir == Right && pos < 179)
    //increase the position of the servo (turn it clockwise)    
    pos += servoSpeed;
  //Otherwise, dont change the servos position
    //Don't Move
    pos = pos;
  //Now that we have an updated position, send it to the servo.
void MoveGearBox(RobotDirection dir)
  //If the direction is Forward
  if(dir == Forward)
   //Send a high pulse to motA_1 and motB_1;
   //low pulse to motA_2 and motB_2 to make the gearbox move forward
   digitalWrite(E1, HIGH);
   digitalWrite(motA_1, HIGH);
   digitalWrite(motA_2, LOW);
  //If the direction is Backwards
  else if(dir == Backwards)
  //Send a high pulse to motA_2 and motB_2;
  //low pulse to motA_1 and motB_1 to make the gearbox move backwards
    digitalWrite(E1, HIGH);
    digitalWrite(motA_1, LOW);
    digitalWrite(motA_2, HIGH);
    //don't Move
    digitalWrite(E1, LOW);    
    digitalWrite(motA_1, LOW);
    digitalWrite(motA_2, LOW);


Back Back to top