Go Down

Topic: Servo 2 axes Turret  (Read 185 times) previous topic - next topic

shlet

Hi i am new to this stuff so it might be obvious or dump, but why doesn't this work?
Code: [Select]

#include <Servo.h>

Servo servox;
Servo servoy;
 int xp=11;
 int xm=10;
 int yp=9;
 int ym=8;
 int f=7;
 int posx=0;
 int posy=0;

void setup()
{
  servox.attach(13);
  servoy.attach(12);
  pinMode (xp,INPUT);
  pinMode (xm,INPUT);
  pinMode (yp,INPUT);
  pinMode (ym,INPUT);


}

void loop()
{
servox.write(posx);
  if(digitalRead(xp),HIGH);
  {
    posx=posx+1;

  }
 
  if(digitalRead(xm),HIGH);
  {
    posx=posx-1;
   
  }
  if(digitalRead(yp),HIGH);
   
  {
    posy=posy+1;

  }
  if(digitalRead(ym),HIGH);
   
  {
    posy=posy-1;

  }

}

please help if you can


PaulS

Code: [Select]
  if(digitalRead(xp),HIGH);
The comma operator is NOT the comparison operator.

The result of the comma operator is as if you had written
Code: [Select]
if(HIGH)
which is, obviously, useless.
The art of getting good answers lies in asking good questions.

Go Up