Electronic Components Datasheet Search |
|
DEV-09760 Datasheet(PDF) 5 Page - SparkFun Electronics |
|
DEV-09760 Datasheet(HTML) 5 Page - SparkFun Electronics |
5 / 9 page const byte PIN_ANALOG_X = 0; const byte PIN_ANALOG_Y = 1; const int X_THRESHOLD_LOW = 505; const int X_THRESHOLD_HIGH = 515; const int Y_THRESHOLD_LOW = 500; const int Y_THRESHOLD_HIGH = 510; int x_position; int y_position; int x_direction; int y_direction; void setup() { Serial.begin(9600); } void loop () { x_direction = 0; y_direction = 0; x_position = analogRead(PIN_ANALOG_X); y_position = analogRead(PIN_ANALOG_Y); if (x_position > X_THRESHOLD_HIGH) { x_direction = 1; } else if (x_position < X_THRESHOLD_LOW) { x_direction = 1; } if (y_position > Y_THRESHOLD_HIGH) { y_direction = 1; } else if (y_position < Y_THRESHOLD_LOW) { y_direction = 1; } if (x_direction == 1) { if (y_direction == 1) { Serial.println("leftdown"); } else if (y_direction == 0) { Serial.println("left"); } else { // y_direction == 1 Serial.println("leftup"); } } else if (x_direction == 0) { if (y_direction == 1) { Serial.println("down"); } else if (y_direction == 0) { Serial.println("centered"); } else { // y_direction == 1 Serial.println("up"); } } else { // x_direction == 1 if (y_direction == 1) { Serial.println("rightdown"); } else if (y_direction == 0) { Serial.println("right"); Page 5 of 9 |
Similar Part No. - DEV-09760 |
|
Similar Description - DEV-09760 |
|
|
Link URL |
Privacy Policy |
ALLDATASHEET.COM |
Does ALLDATASHEET help your business so far? [ DONATE ] |
About Alldatasheet | Advertisement | Datasheet Upload | Contact us | Privacy Policy | 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 |