Professional Documents
Culture Documents
Ultrasonic Sensor To Control A DC Motor Using The PWM Output of An Arduino
Ultrasonic Sensor To Control A DC Motor Using The PWM Output of An Arduino
Download Favorite
By Simple-Circuits
SimpleCircuits More by
the author:
Follow
Hello everyone! In this project we will be controlling the direction of a motor using two
ultrasonic ranging sensors.
If both of the sensors or none of the sensors are triggered at the same time, the motor will
not spin
This simple project is helpful if you want to build a car that is capable of avoiding obstacles.
Two 9v Battery
A Motor
and...
https://www.youtube.com/channel/UCh5aXlcWXmVQ4ipj0...
Teacher Notes
I used staple clips instead of jumper wires for optimized cable management. This is
completely optional and you can use jumper wires as an alternative.
This was covered in the previous Instructable where we connected the 9v battery to the
DC motor. In this project, we will be using the left and right sensors to control the direction
of the motor.
Step 3: Code!
Don't forget to include the New pinglibrary. This allows you to communicate with multiple
ultrasonic sensors easily.
//motor control:
//0 is LOW
//1 is HIGH
// digitalWrite(Relay1, 1);
// digitalWrite(Relay2, 0);
// digitalWrite(Relay1, 0);
// digitalWrite(Relay2, 1);
// motor(off) //
digitalWrite(Relay1, 0);
// digitalWrite(Relay2, 0);
// motor (off)
// digitalWrite(Relay1, 1);
// digitalWrite(Relay2, 1);
Step 4: Done
If everything was done correctly, the rotation of the motor will be controlled by the objects
that trigger the ultrasonic sensors.
As always, you can modify the code and change the voltage for your own projects.
Participated in the
View Contest
Move It
I Made It!
Recommendations
Embedded LED 3D Printed Christmas Arduino Wedding Photo Booth - 3D Arduino and Raspberry Pi Powered Pet
Internet of Things
Tree by maketvee in LEDs Printed Parts, Automated... by DIY Monitoring System by Technovation in
Class
Machines in Arduino Arduino
23,719 Enrolled
w 1 66 8 4.1K 105 8 7.8K 90 8 9.1K
V |
Add Tip Ask Question Post Comment
Discussions
Post Comment
Cooking
© 2019 Autodesk, Inc. Terms of Service | Privacy Statement | Privacy settings | Legal Notices & Trademarks