Permalink
Browse files

funcione para saber hacia donde se mueve

  • Loading branch information...
chepecarlos committed Apr 28, 2012
1 parent 3dc1303 commit 8bbcd6aec9dd4bd638c4bc6c89fa26815add88a7
Showing with 19 additions and 1 deletion.
  1. +19 −1 BrasoAndruino.pde
View
@@ -2,16 +2,34 @@
int PoxX = 90; //Variable de la posicion orizontal del joystick
int VecX = 0; //Variale de hacia donde esta inclinado
+int JoyX = A0;
+
+int ErrorJOY = 30; //Sensiblilidad del braso
void setup() {
Serial.begin(9600);//Inicar el puerto serial
for( int i = 2; i <= 6 ; i++){
pinMode( i , INPUT);
digitalWrite( i, HIGH);
- }
+ }//Iniciando los botones
+
}
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.