I am supposed to make I spherical robot as in the proposal but it required a hamster ball of 20cm diameter at least which I couldn't find, but I could find a hamster ball with 11.5cm diameter, so I decided to change the explained mechanism in the proposal.
My project is a robot with two wheels which move forward, backward, right and left.
when it's dark the above lamp should be lit
the ultrasonic sensor work as the robot's eye, when something get closer it makes a sound
and there is two modes:
tracer mod: it's enabled when I push square button on the app and when I shake my hand in front of the robot, then the robot see if I am close it goes backward, and if I am far it goes forward
random movement: the robot will move around the place and avoid in barriers
[🢁]: move forward
[🢃]: move backward
[🢂]:
when pressed first time: turn right
when pressed second time: rotate clockwise fast
[🢀]:
when pressed first time: turn left
when pressed second time: rotate anticlockwise fast
[ SELECT]: make sound
[ △ ]: Turn the lamp on and off
[ X ]: Stop any movement or any mod
[ O ]: Mod 2
[ ▢ ]: Mod 1
this stage was the hardest one because I have only 11.5cm to build my robot in. I make the first design but it failed to be 11.5cm in size, then I tried to think about another design.
First I downloaded and imported all the components I need to Fusion 360
choose "Open from my computer"
the gray box is supposed to be the battery
Then I create a small plywood for Arduino and L298N motor driver. I take assembly and L298N dimensions by making projection for each of them
I assemble all electrical parts and plywood
Then I make a sphere and assemble it with the 2 motors and the rest of the parts
The last thing was two shafts to connect between the two motors and the two wheels
I saved the shaft as "STL" and open it with Cura software
Then I export this design as "GCODE" and use the 3D printer machine to print the shaft
I export the two plywood sketches as "DXF" and open it with LaserWorks
List of components I used:
Arduino UNO
Bluetooth module - HC-05
LRD sensor - LM393
Ultrasonic sensor
9V lamp
Relay module
7.4V Lithium battery
Motor driver - L298N
Two DC motors
Buzzer
Small breadboard
jumpers
bolts and nuts
Input components:
Ultrasonic sensor
LDR sensor
Serial Input
Action components:
two motors for movement
buzzer
lamp
Function:
when a body is closer than 20cm to the Ultrasonic sensor the buzzer make sound .
when there is soft lighting the LDR sensor read that and the lamp is turned on
With the Serial Input I can send a number from 0 to 8 through the mobile app, each number do a specific function as explained in "Project Ideation" sector
This is a diagram of the circuit (using Fritzing software)
I used 7.4V battery to power my robot, the output voltage go directly to the motor driver L298N and the 9V lamp. Then I get 5V output from the motor driver through its regulator which power the Arduino, and the rest of the components.
When I asked the instructors "why using 7.4V Lithium battery instead of a 9V or 12V battery?", the answered because it has strong current which is suitable for the circuit and it can be recharged.
and there is a small component should be connected to the battery. it show the voltage of each cell in the battery and the total voltage.
when the voltage go below specific limit this component make a loud warning sound, to warn that the battery is about to run out
and there is a charger for the battery, when the three LED are green then the battery is full charged, else it will be red and needs more time for recharging
the warning sound for the battery
First part of coding was defining variable
unsigned long myTime => I used this variable for calculating time difference using millis() function to solve an issue I faced with the LDR sensor.
char serial => for serial connection which should carry a value from 0 to 8
bool closeDistance => to check if any body is closer than 20cm or not
int movMode => to control movement mod (forward, backward, right, left, rotating left or right.
bool lampOn => to contole the lamp
int distance => to save the current distance in this variable
int autoMode => will carry only (0, 7, 8), and this is for automatic mode (O, ▢)
int x1=0, x2=0, x3=0 => I used these variables to help me to check if anyone is shaking his hand in front of the robot or is there a difference in distance reading in specific way.
int speedMotor1 = 170, speedMotor2 = 195 => to control motors speed
int buzzer => number of the buzzer's pin in Arduino
then the functions... I write the functions at the end of the code but to call them I should define them at the first as I write here.
movment function is responsible for the movement of the motors.
when dir = 0, the motors stops
dir = 1, to go forward
dir = 2, to go backward
dir = 3, to turn right
dir = 33, to rotate right
dir = 4 to turn left
dir = 44, to rotate left
if choose a direction then choose the opposite direction the motors stop
setup function:
loop function: I divided into two main parts first is getting serial data the second is for sensors and mods
the second part of loop function:
After wiring and coding, I cut the plywood on the laser cutting machine and assemble all parts together then I tested the function to make sure it works, and fortunately , every thing goes well
then I make the shape as the design in Fusion 360.
the most risky steps was making holes in the hamster ball as if anything goes wrong it will cost me additional time and another hamster ball
Then I fixed the motor with screws in the to sides of the ball and start making holes for the lamp, LDR sensor, ultrasonic sensor, and the switch.
Then when I start to test it that's what happened :)
After the first experiment I note there was 3 main problems
the two motor are not in the same axis. I could fix it by adjusting the screws that connects the motors with the hamster ball
the ball weight was light so the ball was revaluating instead of the wheels. I could fix it by adding some weights to the sphere as shown in the below figure
when the press to the robot to go forward it turns right, and this is because one motor is faster than the other, I adjust the speed from programming
Finally, this is the result
Automatic mode
Manual mode
I was always asking for a feedback from the first step which was choosing the design.
I couldn't find a hamster ball of 25cm so I asked my teammates and my instructors of the best solution the and whether I will change the design or not, and I find the best thing is do change the design and the mechanism
then they helped me during facing the problems I have explained below
and also I give a feedback to my teammates and help them in some ode logics and fusion design.
I helped Ahmed Saeed in the design in Fusion 360.
what is supposed to be done
what I did
the bigest challenge was to design my robot at small as I can to be enable to assemble it in the hamster ball which has a diameter of 11.5cm
After the first experiment I note there was 3 main problems
the two motor are not in the same axis. I could fix it by adjusting the screws that connects the motors with the hamster ball.
the ball weight was light so the ball was revaluating instead of the wheels. I could fix it by adding some weights to the bottom of the sphere as shown in the below figure
when the press to the robot to go forward it turns right, and this is because one motor is faster than the other, I adjust the speed from programming, and this was a long and hard step because each time a experiment the speed I should assemble all the robot parts together to check the speed, if the speed is not suitable I re-assemble all the parts again to connect the robot with my laptop and upload the new code
i could add IR sensors to make it easer for the robot following something that moves in many direction
and I could add RBG LEDs to the robot and make it affect by rotary of by the speed or else