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