i have continuous rotating servo. press spin counter-clockwise , c clockwise. , b stopping it. i'm not pressing buttons , servo still pins. slowly. because of voltage? or servo broken? servo needs 6.6v , arduino can supply 5v servo still turns.
here code btw:
#include <servo.h>
servo myservo;
int pos = 0;
void setup() {
// initialize serial communication:
serial.begin(9600);
// initialize led pins:
myservo.attach(9);
}
void loop() {
// read sensor:
if (serial.available() > 0) {
int inbyte = serial.read();
// different depending on character received.
// switch statement expects single number values each case;
// in exmaple, though, you're using single quotes tell
// controller ascii value character. for
// example 'a' = 97, 'b' = 98, , forth:
switch (inbyte) {
case 'a':
for(pos = 0; pos <= 180; pos += 1) // goes 0 degrees 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo go position in variable 'pos' asdddddddd
delay(5); // waits 15ms servo reach position
}
break;
case 'b':
myservo.write(80);
delay(10000);
break;
case 'c':
for(pos = 180; pos>=0; pos-=1) // goes 180 degrees 0 degrees
{
myservo.write(pos); // tell servo go position in variable 'pos'
delay(15); // waits 15ms servo reach position
}
break;
}
}
}
here code btw:
#include <servo.h>
servo myservo;
int pos = 0;
void setup() {
// initialize serial communication:
serial.begin(9600);
// initialize led pins:
myservo.attach(9);
}
void loop() {
// read sensor:
if (serial.available() > 0) {
int inbyte = serial.read();
// different depending on character received.
// switch statement expects single number values each case;
// in exmaple, though, you're using single quotes tell
// controller ascii value character. for
// example 'a' = 97, 'b' = 98, , forth:
switch (inbyte) {
case 'a':
for(pos = 0; pos <= 180; pos += 1) // goes 0 degrees 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo go position in variable 'pos' asdddddddd
delay(5); // waits 15ms servo reach position
}
break;
case 'b':
myservo.write(80);
delay(10000);
break;
case 'c':
for(pos = 180; pos>=0; pos-=1) // goes 180 degrees 0 degrees
{
myservo.write(pos); // tell servo go position in variable 'pos'
delay(15); // waits 15ms servo reach position
}
break;
}
}
}
is 80 write cr servo stop it? seems odd.
Arduino Forum > Using Arduino > Programming Questions > My CR servo won't stop rotating.
arduino
Comments
Post a Comment