Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1.  
  2. char button0=3, button1=4, button2=5, button3=6;
  3.  
  4. void setup(void)
  5. {
  6.  
  7.   pinMode(button0, INPUT);      //Set the Joystick button 0 as an input
  8.   digitalWrite(button0, HIGH);  //Enable the pull-up resistor on button 0
  9.  
  10.   pinMode(button3, INPUT);      //Set the Joystick button 3 as an input
  11.   digitalWrite(button3, HIGH);  //Enable the pull-up resistor on button 3
  12.  
  13.   Serial.begin(9600);           //Turn on the Serial Port at 9600 bps
  14. }
  15.  
  16. void loop(void)
  17. {
  18.  
  19.   //envia datos a Processing, dependiendo de la accion realizada en el joystickShield
  20.   if(analogRead(1)>800)
  21.    {
  22.       Serial.print(1);
  23.    }  
  24.     else if(analogRead(1)<200)
  25.     {
  26.        Serial.print(2);  
  27.     }
  28.  
  29.   if(analogRead(0)>800)
  30.    {
  31.       Serial.print(3);
  32.    }  
  33.     else if(analogRead(0)<200)
  34.     {
  35.        Serial.print(4);  
  36.     }
  37.    
  38.     if(digitalRead(button0)==0)
  39.    {
  40.       Serial.print(5);
  41.    }  
  42.    
  43.    if(digitalRead(button3)==0)
  44.     {
  45.        Serial.print(6);  
  46.     }
  47.    
  48.   //Wait for 100 ms, then go back to the beginning of 'loop' and repeat.
  49.  delay(100);
  50. }