In this project, we will make a toy car. Whenever someone or something gets too close to it, it will move away. The closer you are to the car, it will try to move away faster from you. This might be a good toy for your pet dog/cat.
Don’t have a Magicbot?If you do not have a magicbot, do not worry. You can use four Ultrasonic sensors. Also you will have to make your own custom robot that can carry all the four ultrasonic sensors, the board and the battery.
Circuit and pin ConnectionsFirst, let’s figure out the pin connections for the ultrasonic sensors. You can connect the Trigger and Echo pin together as shown below in the diagram
It is easier if you make a mount and place the sensors on the mount and then position the mount on the magicbot. You can make a mount as shown below for an example.
After mounting the sensors, our toy car looks like this!
Remember that you have to position them on the magicbot in four directions as shown below (F-Forward, B-Backword, etc)
Connect the pins to the relevant ports on Magicbit with jumper cables as shown in the above image. After everything is done correctly, our toy car looks like this.
- Left motor is connected to pins 16 and 17.
- Right motor is connected to pins 18 and 27
Note that magicbit has inbuilt motor drivers.
Upload the given code to the magicbit before installing it on magicbot.
Troubleshooting- If you want to change the response distance, change the limit variable in the program to the minimum distance that you want your car to start motion.
- If you are not using Magicbot, you might have to figure out the motor rotation direction on your own. Try changing motor pins(M1A with M1B and M2A with M2B) Try a few combinations to figure out their rotation directions(Refer to the functions in the code).
Comments
Please log in or sign up to comment.