IOT Virtual Lab
Home
Simulation Window
Go Back
Interfacing of Arduino with Servo Motor :
ARDUINO CODE
#include
int servoPin = 9; Servo servo; int angle = 0; // servo position in degrees void setup() { servo.attach(servoPin); } void loop() { // scan from 0 to 180 degrees for(angle = 0; angle < 180; angle++) { servo.write(angle); delay(100); } // now scan back from 180 to 0 degrees for(angle = 180; angle > 0; angle--) { servo.write(angle); delay(100); } }
Start Simulation