I have an old analog joystick that I took apart and I found it had three potentiometers that worked nicely with my Arduino.I wrote some code and I had it read the values of all three potentiometers and display them in the serial monitor window.
Here is the code:
int potx = A0;
int poty = A1;
int pott = A2;
int potxv = 0;
int potyv = 0;
int pottv = 0;
void setup(){
Serial.begin(9600);
}
void loop(){
potxv = analogRead(potx);
potyv = analogRead(poty);
pottv = analogRead(pott);
Serial.print("X Value:");
Serial.print(potxv , DEC);
Serial.print("Y Value:");
Serial.print(potyv , DEC);
Serial.print("T Value:");
Serial.print(pottv , DEC);
delay(500);
}
* NOTE: this code is made to work in the Arduino IDE although it may work in others.
I am thinking about posting this as a project on the MAKE magazine website.
That's all for now.
Here is the code:
int potx = A0;
int poty = A1;
int pott = A2;
int potxv = 0;
int potyv = 0;
int pottv = 0;
void setup(){
Serial.begin(9600);
}
void loop(){
potxv = analogRead(potx);
potyv = analogRead(poty);
pottv = analogRead(pott);
Serial.print("X Value:");
Serial.print(potxv , DEC);
Serial.print("Y Value:");
Serial.print(potyv , DEC);
Serial.print("T Value:");
Serial.print(pottv , DEC);
delay(500);
}
* NOTE: this code is made to work in the Arduino IDE although it may work in others.
I am thinking about posting this as a project on the MAKE magazine website.
That's all for now.
Comments
Post a Comment