Arduino: Sensitive Robot




Introduction: Arduino: Sensitive Robot

About: Hi, my name is Nikodem Bartnik. I live in Poland, I'm 18 years old. I like to program and create robots, devices and things. In the future, I want to start a company that creates new technology. Right now I ...


I want to show you how you can build a robot with an Arduino and a few other parts. So what do we need?

  • Arduino. I have leonardo but it's not important
  • H bridge TB6612FNG or other
  • chassis for robot for example DAGU DG012-SV or hand-made
  • ultrasonic sensor
  • servo
  • 2 blue leds
  • buzzer
  • photoresistor
  • resistor 1,2 k Ω
  • breadboard
  • cables, tape, screws, batteries

Step 1: Build Chassis

If you are doing the chassis remember about motors. It's must have sufficient power to move your robot.

If you bought chassis you must submit it.

Now it's time to put batteries. I use box for 5 AA batteries but if you have larger motors you need more batteries.

Step 2: Connect All Things

If you have TB6612FNG H bridge you can connect it's to arduino as below if not you need slightly change it.

For connect it I use 170 holes breadboard because this breadboard it small and can be located on the arduino.

1. Ultrasonic sensor:

-Trig--> 2 pin Arduino

-Echo--> 1 pin Arduino

-VCC --> 5V Arduino

-GND --> GND Arduino

2. Servo:

-GND --> GND Arduino
-VCC --> 5V Arduino
-Data--> 9 pin Arduino

3.H bridge:

-all mass (GND) to mass in Arduino
-VCC -->5V Arduino
-A01 --> motor1 mass(-)
-A02 --> motor1 power(+)
-B02 --> motor2 mass(-)

-B01 --> motor2 mass(-)

-VMOT--> VIN Arduino

-PWMA--> 6 pin Arduino

-AIN1 --> 8 pin Arduino
-AIN2 --> 7 pin Arduino
-BIN2 --> 4 pin Arduino
-BIN1 --> 3 pin Arduino
-PWMB--> 5 pin Arduino


-GND(-) --> GND Arduino

-VCC(+)--> 11 pin Arduino

5. Leds:

-Both VCC (+) from leds to 10 pin Arduino

-Both GND(-) from leds to GND Arduino

Long cables tied a piece of wire.


On image you can see how it's connect. Resistor have 1,2 k Ω

Step 3: Insert All Things

Now you must insert all things on chassis. I use 4 screws M3 to screws Arduino and chassis, between Arduino and chassis I gave a piece of straw. Breadboard located on arduino. I glued Ultrasonic sensor with double sided tape to servo and servo to chassis with black tape. Leds is on ultrasonic sensor on tape. Cables from leds and ping sensor need enough space because it moves.

Step 4: Program 1

Robot with this program after watch obstacles go back watch on left and right and drive to this site where it has more space and when it back make sound. When is dark leds turn on when is brightly leds turn off. Below I added the code, in the comments is an explanation of the code. After loading this code you can start robot.

Step 5: Program 2

Robot with this program can ride in maze. Construction it's the same only code is slightly other.

Step 6: Start Robot

Now you can start your robot. Below i added films with my robot. First one is test, second one is complete robot with first and second program.

If you come from Poland this is my website with instruction is in polish:



    • Water Contest

      Water Contest
    • Fix It! Contest

      Fix It! Contest
    • Creative Misuse Contest

      Creative Misuse Contest

    19 Discussions

    گروه تولیدی بازرگانی ال ای دی پانل با دارا بودن سابقه درخشان در زمینه
    واردات از کشور های مختلف و نیز تولید انواع تابلو روان و <a href="">تلویزیون
    شهری</a>تبلیغاتی ، با به کاری
    گیری نیروی متعهد و متخصص با هدف ارائه خدمات بازرگانی و تولیدی فعالیت می نماید که
    واحد بازرگانی ال ای دی پانل با دارا بودن
    شرکای تجاری معتبر در کشورهای چین ، تایوان و کره جنوبی اقدام به واردات کالاهای الکترونیکی من جمله
    قطعات تابلو روان ، <a href="">قطعات
    تلویزیون شهری</a>و تجهیزات نور پردازی با بهترین
    کیفیت و مناسب ترین قیمت مینماید و نیز واحد تولید ال ای دی پانل فعالیت خود را در زمینه ساخت و تولید
    انواع تابلو روان و نمایشگر شهری LED با مشخصات مختلف
    و نیز تولید انواع قاب تابلو روان ، کابینت تابلو روان led و کابینت <a href="">تلویزیون
    شهری</a>می نماید.

    great project and the code is perfectly working

    Yes, you need to add this:

    light=  analogRead(A0);
        digitalWrite(10, HIGH);
        digitalWrite(10, LOW);

    Write when you are done.

    Czas is time in polish language
    :-) sory for the confusion. Lights work?

    No the lights are still not working. And after using your program robot is stopping after every two to three seconds and scanning and moving and stopping for again two to three seconds and is not moving like you have shown in your video. And sorry for disturbing you on your holiday.

    No problem, I'm curious why this is not working. Robot on my movie stops at 70 milliseconds because when engines works is not enough energy for ultrasonic sensor. Mayby you have the same problem. Below I add code I hope it's good.

    //define trig and echo for ultrasonic sensor
    #define trig 2
    #define echo 1
    //add library
     //Servo definition
    Servo myservo;  
    //Pin definition for H bridge
    int pwmMotorA=6;
    int pwmMotorB=5;
    int ForwardA=8;
    int BackA=7;
    int ForwardB=3;
    int BackB=4;
    /*ultrasonic sensor
    dist1-left scan
    dist2-roward scan
    dist3-right scan
    int czas, dist2, dist1, dist3, light;
    void setup() {    
      //servo definition
      pinMode(11, OUTPUT);
      pinMode(A0, INPUT);
      pinMode(10, OUTPUT);
      //ultrasonic sensor
      pinMode(trig, OUTPUT);
      pinMode(echo, INPUT);   
      //PWM motor A
      pinMode(pwmMotorA, OUTPUT); 
     // Motor A move back
      pinMode(ForwardA, OUTPUT); 
    // Motor A move back
      pinMode(BackA, OUTPUT);   
      //PWM motor B
      pinMode(pwmMotorB, OUTPUT);
      // Motor B move forward
      pinMode(ForwardB, OUTPUT); 
      // Motor B move back
      pinMode(BackB, OUTPUT); 
      //motors speed 
      analogWrite(pwmMotorA, 255);
      analogWrite(pwmMotorB, 255);
    //robot turn left
    void Left(){
      digitalWrite(ForwardA, LOW); 
      digitalWrite(BackA, HIGH);
      //Ustawienie kierunku obrotów B
      digitalWrite(ForwardB, HIGH); 
      digitalWrite(BackB, LOW);
    //robot turn right
    void Right(){
      digitalWrite(ForwardA, HIGH); 
      digitalWrite(BackA, LOW);
      digitalWrite(ForwardB, LOW); 
      digitalWrite(BackB, HIGH);
    //robot move forward
    void Forward(){
      digitalWrite(ForwardA, HIGH); 
      digitalWrite(BackA, LOW);
      digitalWrite(ForwardB, HIGH); 
      digitalWrite(BackB, LOW);
    //robot move back
    void Back(){
      digitalWrite(ForwardA, LOW); 
      digitalWrite(BackA, HIGH);
      digitalWrite(ForwardB, LOW); 
      digitalWrite(BackB, HIGH);
    //ultrasonic sensor scan forward
    void ScanForward(){
        digitalWrite(trig, HIGH);
        digitalWrite(trig, LOW);
        czas = pulseIn(echo, HIGH);
        dist2 = (czas/2) /29.1;
    //ultrasonic sensor scan left 
    void ScanLeft(){
        digitalWrite(trig, HIGH);
        digitalWrite(trig, LOW);
        czas = pulseIn(echo, HIGH);
        dist1 = (czas/2) /29.1;
    //stop robot
    void Stop(){
      digitalWrite(ForwardA, LOW); 
      digitalWrite(BackA, LOW);
      digitalWrite(ForwardB, LOW); 
      digitalWrite(BackB, LOW);
    //ultrasonic sensor scan right
    void ScanRight(){
        digitalWrite(trig, HIGH);
        digitalWrite(trig, LOW);
        czas = pulseIn(echo, HIGH);
        dist3 = (czas/2) /29.1;
    //led and photoresistor
    void Led(){
      light=  analogRead(A0);
        digitalWrite(10, HIGH);
        digitalWrite(10, LOW);
    void loop() {
        //buzzer on
        digitalWrite(11, HIGH);
     //buzzer off
        digitalWrite(11, LOW);

    Well I am actually using the same program. Well what ohm resistor we should use I think I am using 4K ohm resistor. Is it necessary to use a resistor?

    Yes but resistor must have 1,2k ohm

    I am also trying to make it but there is some error occurring. The Robot is not moving and the lights are on every time

    2 replies

    Mayby you have other H bridge or you have wrong connected. On fritzing image I wtong I'am sory. 5V change with mass and mass change with resistor. I hope you understand. You can write an e-mail if you want on Now I'm on holiday, I haven't Arduino and computer with software but if you have more problem ask me I'll try to help you.

    Hey the motor problem is solved but the led problem is still there. Is there any problem in program.


    All parts including arduino costs 100$ but i bought all things in Poland.

    Hey Nikus what inspired u to make this robot and y did u make this robot??

    1 reply


    I have arduino from month and I wanted to make robot so I bought chassis, ping sensor and some other parts needed and I did a robot. It's simple :)