| Electronic Components Datasheet Search |
|
DEV-09760 Datasheet(PDF) 2 Page - SparkFun Electronics |
|
|
|||||||||||||||||||||||||||||
DEV-09760 Datasheet(HTML) 2 Page - SparkFun Electronics |
|
2 / 9 page ![]() • Basic Arduino code (printing joystick values and button presses to the console) • Crazy Arduino code (controlling a melody and tempo with the joystick) • Basic Processing code (basic Processing integration) • Advanced Processing code (painting on a window) If you have no idea what to do with a joystick, checkout this video: How do I make it work? Once you've got the shield assembled, you can begin to change the example code to make the joystick do your bidding: • How do I find the current position of the joystick? • How do I find the current direction of the joystick? • How do I set up the Arduino so I can know when a button has been pushed on the Joystick Shield? • How do I know when a button on the Joystick Shield has been pressed? • How can I avoid repeating the setup code for each button? • How can I use the joystick with Processing (and Firmata)? How do I find the current position of the joystick? The position of the joystick is calculated from the two potentiometers in the joystick. The joystick can move in two dimensions which typically would represent X and Y coordinates but could represent any two dimensional quantity. To read the potentiometers we use the analogRead() function which returns a number from 0 to 1023. We need to supply an analog pin number to the function—for the joystick shield the X position is read from analog pin 0 and the Y position is read from analog pin 1: Serial.println(analogRead(0)); // Prints current X position Serial.println(analogRead(1)); // Prints current Y position It is a good technique—because it clarifies your intent—to use ''constants'' for values that will not change when your sketch runs. With this in mind, the following sketch snippet sets up constants for the analog pins used and prints the current X and Y positions to the serial console: Page 2 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 |