Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char button0=3, button1=4, button2=5, button3=6;
- void setup(void)
- {
- pinMode(button0, INPUT); //Set the Joystick button 0 as an input
- digitalWrite(button0, HIGH); //Enable the pull-up resistor on button 0
- pinMode(button3, INPUT); //Set the Joystick button 3 as an input
- digitalWrite(button3, HIGH); //Enable the pull-up resistor on button 3
- Serial.begin(9600); //Turn on the Serial Port at 9600 bps
- }
- void loop(void)
- {
- //envia datos a Processing, dependiendo de la accion realizada en el joystickShield
- if(analogRead(1)>800)
- {
- Serial.print(1);
- }
- else if(analogRead(1)<200)
- {
- Serial.print(2);
- }
- if(analogRead(0)>800)
- {
- Serial.print(3);
- }
- else if(analogRead(0)<200)
- {
- Serial.print(4);
- }
- if(digitalRead(button0)==0)
- {
- Serial.print(5);
- }
- if(digitalRead(button3)==0)
- {
- Serial.print(6);
- }
- //Wait for 100 ms, then go back to the beginning of 'loop' and repeat.
- delay(100);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement