Skip to content

Commit

Permalink
funcione para saber hacia donde se mueve
Browse files Browse the repository at this point in the history
  • Loading branch information
chepecarlos committed Apr 28, 2012
1 parent 3dc1303 commit 8bbcd6a
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion BrasoAndruino.pde
Expand Up @@ -2,16 +2,34 @@


int PoxX = 90; //Variable de la posicion orizontal del joystick int PoxX = 90; //Variable de la posicion orizontal del joystick
int VecX = 0; //Variale de hacia donde esta inclinado int VecX = 0; //Variale de hacia donde esta inclinado
int JoyX = A0;

int ErrorJOY = 30; //Sensiblilidad del braso


void setup() { void setup() {
Serial.begin(9600);//Inicar el puerto serial Serial.begin(9600);//Inicar el puerto serial


for( int i = 2; i <= 6 ; i++){ for( int i = 2; i <= 6 ; i++){
pinMode( i , INPUT); pinMode( i , INPUT);
digitalWrite( i, HIGH); digitalWrite( i, HIGH);
} }//Iniciando los botones

} }


void loop() { void loop() {
VecX = Movimiento_JOY();
Serial.println(VecX);
Serial.println(analogRead(JoyX));
delay(50);
}

int Movimiento_JOY(){
int V = analogRead(JoyX);
if( V - ErrorJOY > 512 )
return -1;
else if( V + ErrorJOY < 512 )
return 1;
else
return 0;


} }

0 comments on commit 8bbcd6a

Please sign in to comment.