Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

Close

Servo, PROPER, Labels and Code | Electronics Lab

Servo, PROPER, Labels and Code
Version 2 - Last update: Oct 4, 2015

Proper wire coloring are a good idea when prototyping. Easy to burn ports and circuits with mislabeled wires, or wire codes.

///CODE FOR ARDUINO for TESTING, not servo.h library needed:

// Manual servo control // Copyright 2013 by DSKV. // You are free to use and modify this code in your own software.

#define SERVO_PIN 13 // Any pin on the Arduino or Mega will work.

void setup() { pinMode(SERVO_PIN, OUTPUT);

}

int pos = 0; //general position value int lenMicroSecondsOfPeriod = 20 * 1000; // 20 milliseconds (ms) int lenMicroSecondsOfPulse = 1.0 * 1000; // 1.0 ms is 0 degrees

void loop() {

// Servos work by sending a 20 ms pulse. // 1.0 ms at the start of the pulse will turn the servo to the 0 degree position // 1.5 ms at the start of the pulse will turn the servo to the 90 degree position // 2.0 ms at the start of the pulse will turn the servo to the 180 degree position

for (pos = 0; pos

Comments disabled