Advertisement
Guest User

Untitled

a guest
May 27th, 2014
1,140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. //Declare variables
  2. int x = A0;
  3. int y = A1;
  4. int z = 7;
  5.  
  6. void setup()
  7. {
  8.  
  9. //Initialize serial communication
  10. Serial.begin(9600);
  11.  
  12. //Set pinmode to input pullup to not have to use a resistor.
  13. pinMode(7,INPUT_PULLUP);
  14.  
  15.  
  16. }
  17.  
  18. void loop()
  19. {
  20. //Read values from the ports
  21.  
  22. int xVal = analogRead(A0);
  23.  
  24. int yVal = analogRead(A1);
  25.  
  26. int zVal = digitalRead(7);
  27.  
  28. //Print values in the serial
  29.  
  30. Serial.print(xVal, DEC);
  31.  
  32. Serial.print(",");
  33.  
  34. Serial.print(yVal, DEC);
  35.  
  36. Serial.print(",");
  37.  
  38. Serial.print(zVal, DEC);
  39.  
  40. Serial.println();
  41.  
  42. //Add delay to make sure that all values go through without errors
  43. delay (100);
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement