Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. //LABORATORIO 8
  2. // ANDRES SATIZABAL
  3.  
  4. int pinarr=4;
  5. int pinaba=5;
  6. int pinizq=6;
  7. int pinder=3;
  8. int po=A0;
  9. int pa=A1;
  10.  
  11. void setup()
  12. {
  13. //initialize serial communications at a 9600 baud rate
  14. Serial.begin(9600);
  15. pinMode(pinarr, INPUT);
  16. pinMode(pinaba, INPUT);
  17. pinMode(pinizq, INPUT);
  18. pinMode(pinder, INPUT);
  19. pinMode(po, INPUT);
  20. pinMode(pa, INPUT);
  21.  
  22. }
  23. int x;
  24. int y;
  25. void loop()
  26. {
  27. //send 'Hello, world!' over the serial port
  28. x=analogRead(po);
  29. y=analogRead(pa);
  30.  
  31.  
  32. if (y>1022){
  33. Serial.println("arriba");
  34.  
  35. }
  36. if (y<1){
  37. Serial.println("abajo");
  38.  
  39. }
  40. if (x>1022){
  41. Serial.println("der");
  42.  
  43. }
  44. if (x<1){
  45. Serial.println("izq");
  46.  
  47. }
  48. delay(200);
  49. //wait 100 milliseconds so we don't drive ourselves crazy
  50.  
  51. }