Difference between revisions of "The Use of Joystick Sensor"
From Microduino Wiki
(→Development) |
|||
Line 36: | Line 36: | ||
*Other Hardware Equipment | *Other Hardware Equipment | ||
**One USB cable | **One USB cable | ||
− | [[File:module- | + | [[File:module-joystick.jpg|600px|center]] |
===Preparation=== | ===Preparation=== | ||
Line 42: | Line 42: | ||
[[file:mCookie-pir-sensor.JPG|600px|center]] | [[file:mCookie-pir-sensor.JPG|600px|center]] | ||
*Setup 2:Stack the CoreUSB, Hub and Light together and then connect them to the computer with a USB cable. | *Setup 2:Stack the CoreUSB, Hub and Light together and then connect them to the computer with a USB cable. | ||
− | [[file:mCookie- | + | [[file:mCookie-joystick.JPG|600px|center]] |
===Experiment: Detect Analog Brightness Value === | ===Experiment: Detect Analog Brightness Value === | ||
Line 74: | Line 74: | ||
** The top shift value decrease on the Y-axis, close to zero while the downward shift value increases and gets close to 1,023. | ** The top shift value decrease on the Y-axis, close to zero while the downward shift value increases and gets close to 1,023. | ||
===Program Debugging=== | ===Program Debugging=== | ||
− | *Use“analogRead(XX);” to read sensor's input analog value and judge the displacement on both the X-axis and Y-axis. | + | *Use“analogRead(XX);” to read sensor's input analog value and judge the displacement on both the X-axis and Y-axis. |
==Application== | ==Application== |
Revision as of 04:31, 9 November 2015
ContentsOutlineMicroduino-Joystick sensor is equipped with a two-way analog output interface. Its output values correspond to offsets on both the X-axis and Y-axis. It is small and beautiful. Specification
DevelopmentEquipment
Preparation
Experiment: Detect Analog Brightness Value
#define Pin_X A1
#define Pin_Y A0
void setup() {
Serial.begin(9600); //Serial initializing
pinMode(Pin_X,INPUT);
pinMode(Pin_Y,INPUT);
}
void loop() {
int sensorValueX = analogRead(Pin_X); //X-axis input
int sensorValueY = analogRead(Pin_Y); //Y-axis input
Serial.print("ValueX:");
Serial.print(sensorValueX);
Serial.print(",");
Serial.print("ValueY:");
Serial.println(sensorValueY);
delay(100);
}
Program Debugging
Application
Video |