Misbehaving servo


hi chaps
last time tried worked perfectly, though time around using high torque 40kg servo , not behaving expected.

depending on byte of info received, should move servo position, - returns 0 degrees position instead of staying there until byte received.

can see error of ways?
code: [select]

void loop()
{
  // if valid byte, read analog ins:
  if (serial.available() > 0) {
    // incoming byte:
    inbyte = serial.read();
  if(inbyte==1)
  {
    serial.write("q");
pvar=0;   
  }
    if(inbyte==2)
  {
    serial.write("w");
pvar=90;   
  }
    if(inbyte==3)
  {
    serial.write("e");
pvar=120;   
  }
    if(inbyte==4)
  {
    serial.print("y");
digitalwrite(speaker, high);
delay(10000);
digitalwrite(speaker, low);
  }
}

/*  while (serial.available() <= 0) {
    serial.print("b");   
    delay(300);
  }*/
  myservo.write(pvar);
}


i can rule out serial code byte recognition part of code being issue. byte sent works expected.

how servo powered ?
what data type inbyte ?
what values see if print inbyte when serial data available , before writing servo ?


Arduino Forum > Using Arduino > Programming Questions > Misbehaving servo


arduino

Comments

Popular posts from this blog

How do I add a forum to my site? - Joomla! Forum - community, help and support

VIDIOC_S_FMT error 16, Device or resource busy - Raspberry Pi Forums

using a laptop skeleton to build a pi laptop - Raspberry Pi Forums