Skip to content
This repository
Browse code

funcione para saber hacia donde se mueve

  • Loading branch information...
commit 8bbcd6aec9dd4bd638c4bc6c89fa26815add88a7 1 parent 3dc1303
Jose Carlos Garcia Diaz authored April 27, 2012

Showing 1 changed file with 19 additions and 1 deletion. Show diff stats Hide diff stats

  1. 20  BrasoAndruino.pde
20  BrasoAndruino.pde
@@ -2,6 +2,9 @@
2 2
 
3 3
 int PoxX = 90;    //Variable de la posicion orizontal del joystick
4 4
 int VecX = 0;     //Variale de hacia donde esta inclinado
  5
+int JoyX = A0;
  6
+
  7
+int ErrorJOY = 30; //Sensiblilidad del braso
5 8
 
6 9
 void setup() {
7 10
   Serial.begin(9600);//Inicar el puerto serial
@@ -9,9 +12,24 @@ void setup() {
9 12
    for( int i = 2; i <= 6 ; i++){
10 13
       pinMode( i , INPUT);  
11 14
       digitalWrite( i, HIGH);
12  
-    }
  15
+    }//Iniciando los botones
  16
+    
13 17
 }
14 18
 
15 19
 void loop() {
  20
+  VecX = Movimiento_JOY();
  21
+  Serial.println(VecX);
  22
+  Serial.println(analogRead(JoyX));
  23
+  delay(50);
  24
+}
  25
+
  26
+int Movimiento_JOY(){
  27
+  int V = analogRead(JoyX);
  28
+  if( V - ErrorJOY > 512 )
  29
+  return -1;
  30
+  else if( V + ErrorJOY < 512 )
  31
+  return 1;
  32
+  else
  33
+  return 0;
16 34
   
17 35
 }

0 notes on commit 8bbcd6a

Please sign in to comment.
Something went wrong with that request. Please try again.