position

Post test messages here

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
doryJa
 
Posts: 1
Joined: Mon May 12, 2014 7:56 pm

position

Post by doryJa »

my servo is only able to display 45 degree no matter what position i put in, is there anything wrong with my code?
#include <Adafruit_SoftServo.h>

Adafruit_SoftServo myservo;
int pos=70;
int time=0;
void setup() {
OCR0A = 0xAF; // any number is OK
TIMSK |= _BV(OCIE0A);
myservo.attach(0);
}

void loop() {
pos=180;
myservo.write(pos);
delay(10000);
pos=0;
myservo.write(pos);
delay(1000);
}

volatile uint8_t counter = 0;
SIGNAL(TIMER0_COMPA_vect) {
// this gets called every 2 milliseconds
counter += 2;
// every 20 milliseconds, refresh the servos!
if (counter >= 20) {
counter = 0;
myservo.refresh();
}
}

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: position

Post by adafruit_support_bill »

The code looks OK. What kind of servo is it? Post a photo showing how everything is connected.

Locked
Please be positive and constructive with your questions and comments.

Return to “Test Message Forum (closed)”