| Electronic Components Datasheet Search |
|
DEV-09760 Datasheet(PDF) 7 Page - SparkFun Electronics |
|
|
|||||||||||||||||||||||||||||
DEV-09760 Datasheet(HTML) 7 Page - SparkFun Electronics |
|
7 / 9 page ![]() void setup() { pinMode(PIN_BUTTON_RIGHT, INPUT); digitalWrite(PIN_BUTTON_RIGHT, HIGH); pinMode(PIN_BUTTON_LEFT, INPUT); digitalWrite(PIN_BUTTON_LEFT, HIGH); pinMode(PIN_BUTTON_UP, INPUT); digitalWrite(PIN_BUTTON_UP, HIGH); pinMode(PIN_BUTTON_DOWN, INPUT); digitalWrite(PIN_BUTTON_DOWN, HIGH); pinMode(PIN_BUTTON_SELECT, INPUT); digitalWrite(PIN_BUTTON_SELECT, HIGH); } See the next section to learn how to read whether a button is pressed or not. How do I know when a button on the Joystick Shield has been pressed? Once you have set up your Arduino to recognize the buttons (see above) you can tell whether the button is pressed with the digitalRead() function. When the value read is LOW the button is pressed and when the value is HIGH the button is not pressed. if (digitalRead(PIN_BUTTON_LEFT) == LOW) { // Button is pressed } else { // Button is not pressed } The following complete example will print the state of each button and the value of the joystick to the Arduino serial console: Page 7 of 9 |
|
|
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 |
| 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 |