Arduino shield - Joystick

9,99 €
Na zalogi
SKU
ar-sh-js
Arduino shield - Joystick

Arduino shield - Joystick

Joystick Shield še spriključuje direktno na Arduino in ima 4 smerne tipke, 2 taktična gumba in še 1 Joystick

  • Gumb A: Arduino D2 - Up
  • Gumb B: Arduino D3 - Right
  • Gumb C: Arduino D4 - Down
  • Gumb D: Arduino D5 - Left
  • Gumb E: Arduino D6 - Start
  • Gumb F: Arduino D7 - Select
  • X Joystick: Arduino A0
  • Y Joystick: Arduino A1


Dimenzije : 53mm x 87mm

Program - Primer:

int up_button = 2;
int down_button = 4;
int left_button = 5;
int right_button = 3;
int start_button = 6;
int select_button = 7;
int joystick_button = 8;
int joystick_axis_x = A0;
int joystick_axis_y = A1;
int buttons[] = {up_button, down_button, left_button, right_button, start_button, select_button, joystick_button};


void setup() {
for (int i; i < 7; i++) {
pinMode(buttons[i], INPUT);
digitalWrite(buttons[i], HIGH);
}
Serial.begin(9600);
}

void loop() { Serial.print("UP = "),Serial.print(digitalRead(up_button)),Serial.print("\t");
Serial.print("DOWN = "),Serial.print(digitalRead(down_button)),Serial.print("\t");
Serial.print("LEFT = "),Serial.print(digitalRead(left_button)),Serial.print("\t");
Serial.print("RIGHT = "),Serial.print(digitalRead(right_button)),Serial.print("\t");
Serial.print("START = "),Serial.print(digitalRead(start_button)),Serial.print("\t");
Serial.print("SELECT = "),Serial.print(digitalRead(select_button)),Serial.print("\t");
Serial.print("ANALOG = "),Serial.print(digitalRead(joystick_button)),Serial.print("\t");
Serial.print("X = "),Serial.print(map(analogRead(joystick_axis_x), 0, 1000, -1, 1));Serial.print("\t");
Serial.print("Y = "),Serial.print(map(analogRead(joystick_axis_y), 0, 1000, -1, 1));Serial.print("\n");
Serial.print("X = "),Serial.print(analogRead(joystick_axis_x));Serial.print("\t");
Serial.print("Y = "),Serial.print(analogRead(joystick_axis_y));Serial.print("\n");
delay(100);
}

Napišite vaše lastno mnenje
Pregledujete:Arduino shield - Joystick
Vaša ocena
SMAKshop - © 2003-2019 - by SMAK d.o.o., Ob železnici 14, si-1000 Ljubljana - All Rights Reserved.