STEP #5 : test the rotation of the ultra-sonic servo

arduino4fun
Site Admin
Posts: 37
Joined: Mon Jun 06, 2016 1:16 pm

STEP #5 : test the rotation of the ultra-sonic servo

Postby arduino4fun » Thu Jun 09, 2016 7:44 am

We can now test the rotation of the ultra-sonic servo using the code below, the servo will move indefinitely at an angle of 0/45/90 (the
centre) /135/180 degree

Code: Select all

// ----------------------------------------------------------------------------------------------
 // This sketch allows to check the rotation of the ultrasonic servo connected on pin #5
 //
 // https://www.facebook.com/arduino4fun
 // http://www.arduino4fun.com
 // ----------------------------------------------------------------------------------------------

‪#‎include‬ <Servo.h>

Servo MyServo; // Define our Servo

void setup()
 {
 MyServo.attach(5); // servo on digital pin 5
 Serial.begin(9600); // Connect to the serial port , 9600, debug purpose only
 Serial.println("Servo test" );
 }

void loop()
 {
 MyServo.write(0); // Turn Servo Left to 0 degrees
 Serial.println("0");
 delay(1000); // Wait 1 second
 MyServo.write(45); // Turn Servo Left to 45 degrees
 Serial.println("45");
 delay(1000); // Wait 1 second
 MyServo.write(90); // Turn Servo back to center position (90 degrees)
 Serial.println("90");
 delay(1000); // Wait 1 second
 MyServo.write(135); // Turn Servo Right to 135 degrees
 Serial.println("135");
 delay(1000); // Wait 1 second
 MyServo.write(180); // Turn Servo Right to 180 degrees
 Serial.println("180");
 delay(1000); // Wait 1 second
 }


here is the video of the test : https://youtu.be/mD2bttT5Y2o

Return to “Multifunction Bluetooth Controlled Robot Smart Car Kits For Arduino”

Who is online

Users browsing this forum: No registered users and 0 guests