Aim:
To use Arduino or Raspberry Pi Pico to rotate a servo motor when a button is pressed.
Requirements:
- Arduino or Raspberry Pi Pico
- Servo motor
- Push button
- Breadboard & jumper wires
- Arduino IDE (for Arduino) or Thonny (for Pico)
Procedure:
- Circuit Connections
- Connect the servo motor’s signal pin to pin 9 (Arduino) or GP15 (Pico).
- Connect the servo’s VCC to 5V (Arduino) or 3.3V (Pico).
- Connect the servo’s GND to the microcontroller’s ground.
- Button Setup
- Place the push button on the breadboard.
- Connect one side of the button to 5V (Arduino) or 3.3V (Pico).
- Connect the other side to a digital pin through a pull-down resistor to ground (ensures the button reads LOW when not pressed).
- Upload the Code
- Write a program that:
- Reads the button state (pressed or not pressed).
- If pressed → rotate servo from 0° to 90°.
- If not pressed → move servo back to 0°.
- Write a program that:
- Test the System
- Press the button and observe the servo movement.
- Release the button and check if it returns to its original position.