For this week's assignment , I decided to try the idea of my final project, which is moving motors using potentiometers but since this pair was already used in a session, I decided to replace it with a push button.
So I'm going to make it simple as possible, using 1 push button and 1 micro servo motor.
Started by adding all the components needed.
Connected them as shown.
Discovered that in order for the button to work properly with 9V adaptor, a 1K ohm is needed. and the adaptor is needed for the servo motor.
Then, using if condition block:
position of 170 degrees was set when the button is pressed.
Otherwise, it returns to 10 degrees.
Avoided using 0 and 180 as limits of servo motors may take time to move from.
a delay of 150 millisecond was added to show the results properly in real life.
Started by connecting the 5V and GND to the breadboard.
Connected the push button and the servo to the arduino.
made sure all wires are working well.
downloaded the ino file and uploaded it on arduino uno.
When I finished wiring the servo motor didn't respond at all, I had to check all the wiring again but it turned out that I shouldn't be connecting the arduino to the laptop but rather use the 9V adapter since its powerful enough to operate the servo motor.
Also, I totally forgot that resistance is needed when using push button, as after adding the 1K ohm resistor on the same point of the button leg the circuit worked as intended.
Since this assignment is practically functioning one link of my robotic arm, I feel I took a shortcut and that the robotic arm implementation won't take long.