Electronic Components Datasheet Search
  English  ▼

X  

DEV-09760 Datasheet(PDF) 6 Page - SparkFun Electronics

Part # DEV-09760
Description  Joystick Shield Quickstart Guide
PDF  9 Pages
Scroll/Zoom Zoom In 100%  Zoom Out
Manufacturer  SPARKFUN [SparkFun Electronics]
Direct Link  https://www.sparkfun.com/
Logo SPARKFUN - SparkFun Electronics

DEV-09760 Datasheet(HTML) 6 Page - SparkFun Electronics

  DEV-09760 Datasheet HTML 1Page - SparkFun Electronics DEV-09760 Datasheet HTML 2Page - SparkFun Electronics DEV-09760 Datasheet HTML 3Page - SparkFun Electronics DEV-09760 Datasheet HTML 4Page - SparkFun Electronics DEV-09760 Datasheet HTML 5Page - SparkFun Electronics DEV-09760 Datasheet HTML 6Page - SparkFun Electronics DEV-09760 Datasheet HTML 7Page - SparkFun Electronics DEV-09760 Datasheet HTML 8Page - SparkFun Electronics DEV-09760 Datasheet HTML 9Page - SparkFun Electronics  
Zoom Inzoom in Zoom Outzoom out
 6 / 9 page
background image
} else {
// y_direction == 1
Serial.println("right­up");
}
}
How do I set up the Arduino so I can know when a
button has been pushed on the Joystick Shield?
Before you can know if a button on the shield has been pushed you need to set up
your Arduino to recognize the buttons. Unsurprisingly you will perform this setup in
the... setup() function!
First we define constants for the Arduino pin associated with each button:
// Select button is triggered when joystick is pressed
const byte PIN_BUTTON_SELECT = 2;
const byte PIN_BUTTON_RIGHT = 3;
const byte PIN_BUTTON_UP = 4;
const byte PIN_BUTTON_DOWN = 5;
const byte PIN_BUTTON_LEFT = 6;
If you've used a pushbutton switch before you may have noticed a resistor is normally
required in order to detect a known voltage when the button is not pressed. To reduce
the number of parts required this shield has been designed not to require resistors on
the shield itself. Are you thinking to yourself "if push buttons require resistors and the
shield has no resistors how can we get the shield to work?"? If you're not thinking that
then you can probably skip reading this bit. (And if you're thinking "I'm really hungry" it
might be time to put down the electronics and get some food.)
It turns out your Arduino actually has internal resistors connected to the pins inside
the microcontroller. In order to use the internal resistors we need to "enable the
internal pull-up resistors". If that sounds to you like "hoist the jib and unfurl the main
stay" then I can explain some more:
When a "pull-up" resistor is connected to a push button it means that the voltage level
when the button is not pressed will be HIGH because the resistors "pulls the voltage
level up" to HIGH when the button is not pressed. On a typical Arduino a pin that is
HIGH will be at 5 volts. When the push button is pressed the pin will read as LOW
because there is less resistance between the pin and ground than there is between
the pin and 5 volts.
To enable a pin's pull-up resistor you first set the pin as an input and then enable the
pull-up:
pinMode(PIN_BUTTON_RIGHT, INPUT);
digitalWrite(PIN_BUTTON_RIGHT, HIGH);
The actual code to enable the pull-up doesn't really make any sense if you read it
literally but that's the way it works.
Other than remembering that an unpressed button will read as HIGH with a pull-up
resistor and a pressed button will read as LOW you don't need to remember or
understand the other details.
In order to configure each pin to be an input and enable the pull up resistors we use
the following code:
Page 6 of 9



Html Pages

1 2 3 4 5 6 7 8 9


Datasheet Download

Go To PDF Page


Link URL



Does ALLDATASHEET help your business so far?  [ DONATE ] 

About Alldatasheet   |   Advertisement   |   Contact us   |   Privacy Policy   |   Link to Datasheet    |   Link Exchange   |   Manufacturer List
All Rights Reserved©Alldatasheet.com


Mirror Sites
English : Alldatasheet.com  |   English : Alldatasheet.net  |   Chinese : Alldatasheetcn.com  |   German : Alldatasheetde.com  |   Japanese : Alldatasheet.jp
Russian : Alldatasheetru.com  |   Korean : Alldatasheet.co.kr  |   Spanish : Alldatasheet.es  |   French : Alldatasheet.fr  |   Italian : Alldatasheetit.com
Portuguese : Alldatasheetpt.com  |   Polish : Alldatasheet.pl  |   Vietnamese : Alldatasheet.vn
Indian : Alldatasheet.in  |   Mexican : Alldatasheet.com.mx  |   British : Alldatasheet.co.uk  |   New Zealand : Alldatasheet.co.nz
Family Site : ic2ic.com  |   icmetro.com