Hello my name is Syed and i am a rising senior at Elmont Memorial High School and i did two projects. One starter and the other the main project so for my starter project i built the Ultra Sonic parking sensor which would detect objects in distance or near when the object comes near its radius the buzzer would beep to signal the object is near the car so the driver should remain cautious when parking. As for my main project i built the hexbug line following robot which would follow a black line and spin on certain color of line like on the white surface and the robot would run when it is on the black surface.The reason i chose this project is because i am interested in robots that interact on there own based on the environment independently and not that i have to control the robot itself.


3rd Milestone: The robot is done, but due to the weight issues and the voltage input i was not able to put the head on top of the hexbug. The problem was occurring with my robot was the leg motor was not functional due to the voltage input differences decimated the  Arduino nano so i had to switch the Arduino boards from Nano to Micro so the pins had to be changed. which are on my code like the leg motor the negative is at digital pin 5 and the positive terminal of the motor at 5v to easily work the motor and keep the motor running with enough voltage, but due to the weight issue i had to remove the head and the battery would have to be dragged. The robot itself is able to recognize the line and act upon it. The code is changed because since the current flows from high to low i had to change the digitalWrite (LM, Low) which means when sensor values are above 900 the bot would run and when it is at below 900 the bot would not move so the digitalWrite(LM, HIGH).

hexbug schematic


Syed’s BlueStamp Bill of Materials Template (2)


The challenge has arrived which was programming the robot, so in this milestone was to run the motors. First things first was to initialize the variables like where is the leg and turning motor? So i named the pins in which the LM is the leg motor and TM is the turning motor.  LM was set to 6 meaning digital pin 6, and the TM was set to digital pin 11.  Second step was what are these pins function would be? This is done in void setup() and to set their function is pinMode(), so to set the pins  TM and LM are set to output which means they will be making the gears run by the motor. Now we have to make the IR Sensor to recognize so firstly i would set IR to analog pin 6 and set one of the value to equal zero(the values may vary so that is why i did not put const in front of it). Then in the void setup() type serial.begin(9600) which means the IR sensor  sends data at 9600 bauds. Now in the void loop() where the action keeps repeating. So we type the variable you set the value to zero equal to the analogRead(IR) that will pick up the values. Now we have to write Serial.print(“sensor =”) and the serial.println(the name of the value that was equal to zero).  This will make the values present in your serial monitor. As the values present on the serial monitor you need control structures to set the values by using if else constructions. So if sensor values is higher than 900 then walk and if less then stop and start spinning until you find a black line and start walking.

EXTENDED PROBLEM: If there is a low voltage input then add a transistor to make it amplify by creating a short cut in which you take power from VIN to the positive terminal of the battery  and the negative terminal of the motor to the collector of the transistor. The base to any of the positive wires ( white ones) to the base of the transistor. finally the emitter to the GND and that connection to primary GND  to complete the circuit.

MODIFIER: adding a on/off switch can be useful because the battery if attached  and when  taking out the battery can harm the motor wires, so by inserting the on/off switch can easily help make your robot look neat, organized, and safe. First de-solder the red wire and attach the switch between the red wires just two


My first steps would be to removing the head from the Hex Bug by unscrewing the screws in order to gain access to the two motors.  Second was the cutting of the wires of the battery that we need. Such wires like black and white are needed so cut them to the base as close as possible. You will be left with red and black (picture 1) wires next to each other. Why we didn’t we cut them? Well the black and red wire do not connect with the any of the two motor so as a result we don not need them because we will be using the Arduino nano which itself act as a battery to provide the power via USB connected to laptop or computer. So now you you must have the red and black wires into the battery the green chip and have removed it.  Then we use a jumper wires to connect the black and white wires. But be careful these wires are small and delicate. So now we use the perfboard (Picture 2) make the connection between jumper wires and the Arduino nano.  The wire white is the positive and the black is ground. So we connect the black wires to the GND (ground) and the white wires to any of digital pins, but make sure that you attach the white wire wire of the turning motor to any of the PWM (pulse width module) digital pins. Examples are 3, 5, 6,8,10, and 11. I chose the digital pin 5 on the Arduino nano for leg motor and for turning motor i chose digital pin 11. Then setting up the IR SENSOR which is the QRE1113 Analog. I will explain its function in my next milestone.  There are 3 holes on the IR Sensor which are VCC ( high voltage), Out ( the output), and the GND ( ground). connect the jumper wires pins to their location (GND) to GND on the arduino nano and VCC on sensor to 5v on arduino nano. Lastly connect the OUT to any of the analog pin on the arduino. Analog pins begin with “A.” I chose to connect to A6. If the connect is short connect the jumper wire to that jumper wire and make the connection. If your soldering goes wrong you can always use jumper wires to make the connection. Also my IR sensor is also analog so i have to connect the sensor at the analog.




Picture 2



This is the Ultra Sonic parking sensor. The parking senor as you guessed it is for cars. Basically, the parking sensor detects object and emits a sound when the object is nearby. It helps a driver park easily. The parking sensor’s anatomy is that it has two ultrasonic sensors. One receives a sound and the another emits it. It starts out as my hand for example hovering around the first sensor which receives the sound and these sound waves as a result are converted into electrical energy. The electrical energy may have a high voltage so we use a resistor which limits the amount of voltage and the capacitors store some of the energy.This can be extremely helpful because that power which can be used later without a battery. The wires as you can see in the blue screw connectors provide a passage of this electrical current which arrives at the PCB (the base). The IC sockets provide safety to the dual in line IC (integrated circuits). They work as amplifiers and contain resistors to limit the voltage as the current travels the diodes make sure the current goes in one way.  Up next comes the quartz crystal which keeps the frequency of the electrical current constant. The current goes to the buzzer with the help of a diode and it allows the flow of current one way which would be to the buzzer and the buzzer beeps. One cool trick is that the trim potentiometer basically act as a voltage divider and when lowered the voltage the Sensors can detect objects in their way from more distance and allow the amplification of the sound to be greater.




Leave a Comment

Start typing and press Enter to search