Examples - Electronic Bricks - Electronic Brick Joystick
Analog In - Get user input with the Electronik Brick Joystick.
This program gives you a basic understanding how to use the Joystick Brick.
The Joystick outputs analog signals for the X & Y directions and uses the Z output as a digital button.
Hardware Setup:
/* Example: How to use the 'Analog Sound Sensor Electronic Brick' Usage: Connect the Joystick X output to analog pin 4 on the Seeduino Shield Connect the Joystick Y output to analog pin 5 on the Seeduino Shield Connect the Joystick Z output to digital pin 8 on the Seeduino Shield */ // Define the analog input pin for the sound sensor int x = 4; int y = 5; int z = 8; void setup() { Serial.begin(9600); // Invoke Serial Interface for debugging purposes } void loop() { // Read the sensor values for x y z int Xinput = analogRead(x); int Yinput = analogRead(y); int Zinput = digitalRead(z); // Output to console or computer Serial.print(Xinput); Serial.print(","); Serial.print(Yinput); Serial.print(","); Serial.println(Zinput); // delay the print line output by 0.1 seconds delay(100); }