using arduino and a bluetooth module i want to make a moving mechanism for my final project and i decided to use servo motor to do it in week 8!Â
arduino ide for compiling and debugging
I used tinkercad for design
arduino uno is the brain of the device and i use it to control the components
jumper wires
I used 9V 2 A adapter as the source of power for my project
I used servo motor as my action component
breadboard for wiring
bluetooth module
push button
input components
bluetooth module
push button
output/action component
I used servo motor as my action component
wiring diagram
I USED WIFI MODULE instead of blutooth module because i couldn't find it in tinkercad then connected the rx to tx adn tx to rx in arduino
then connected Ground to gnd in arduino via breadboard
the power /vcc was connected to 5v pin in arduino via breadboard
Servo:
-I connected the ground and power to the gnd and 5v in the breadboard
-then the signal was connected to pin 9
button : I couldn't find the red push button so i used the regular switch but it should do the same job here
the common was connected to cathode and the other terminal was connected to pin 3
let programming begin
at first i included servo and set the digital pins of the button and servo and declared the two moods i choose for servo is the start position at 0 and tthe target position is 180 degrees
and i created servo object called myservo
In void setup i declared the type of every component as i the button is input and servo as output and set that esrvo to the initial position.
in void loop i used if conition that if arduino recived 1 from bluetooth the servo will move to the target position that i determined to be 180
if the arduino recived 2 from bluetooth the servo will move back to the starting position
after that i put if else condition to set the button that when it's pressed the servo moves to the target position and when we leave it it comes back to original position.
wiring process
here is the components without wiring as i did in fusion
here wiring of the push button
the bluetooth module wiring
I used arduino bluecontrol application to control bluetooth
testing
I had a problem with the pin 2 as i was using it for the button and it didn't work so i changed the jumper wires and the pin to troubleshoot the problem and it worked
i think the jumper wire was not working so be sure to test your wires before you use them.