OBJECTIVE
Design and implement a system with an Arduino Nano to control a servo motor, rotating to specific angles like 90 or 180 degrees based on user input or sensor data.
MODULES REQUIRED
- Arduino NANO
- Servo Motor
- Jumper wire
SCHEMATIC DIAGRAM
Connect Servo Motor:
- VCC pin (red) to Arduino Nano 5V.
- GND pin (brown) to Arduino Nano GND.
- Common pin (yellow) to Arduino Nano D2.
ARDUINO CODE
JavaScript
#include <Servo.h>
Servo servo_pin_2;
void setup(){
servo_pin_2.attach(2,530,2600);
}
void loop(){
servo_pin_2.write( 0 );
delay( 2000 );
servo_pin_2.write( 90 );
delay( 2000 );
servo_pin_2.write( 0 );
delay( 2000 );
servo_pin_2.write( 90 );
delay( 1000 );
}
INSTRUCTIONS
- Connect the modules and components as per the schematic diagram.
- Upload the Arduino code into the Arduino board.
- Control a servo motor using an Arduino Nano to rotate to specific angles (e.g., 90° or 180°) based on programmed instructions.
WORKING
- Arduino Nano controls a servo motor to rotate to specific angles (e.g., 90° or 180°) by sending PWM signals via a programmed digital pin.