I am a newbie to Arduino and I am making my way through the "Making Things Talk" exercise book. The fist project is called monkey pong. This project requires two flex resistors. So far I have successfully completed the project but now I want to build a controller for it.
I get good data back from the flex resistor when I wiggle the flex resistor around ranging from 800 to 400 but what if the controler I build is something that flexes the resistors much more subtly like a plastic ruler. My read out then will be something more like 480 to 478 and these min and max numbers are to close together for me to read and use effectively. So is there a way to super sample these numbers, maybe to get float numbers back or change the range so that 450 is 0 and 500 is 100.
Here is the read out I am getting through the serial monitor.
560,576,0,0
559,575,0,0
560,574,0,0
Bellow is my Arduino script that gives me feedback through the serial port.
/*
Sensor Reader
Lamguage: Wiring/Arduino
Reads two analog inputs and two digital inputs and outputs their values.
Connections:
analog sensors on analog input pins 0 and 1
switches on digital i/o pins 2 and 3
*/
int leftSensor = 0; //analog input for the left arm
int rightSensor = 1; //analog input fot the right arm
int resetButton = 2; //digital input for the reset button
int serveButton = 3; //digital input for the serve button
int leftValue = 0; //reading from the left arm
int rightValue = 0; //reading from the right arm
int reset = 0; //reading from the reset button
int serve = 0; //reading form the serve button
void setup() {
//configure the serial connection:
Serial.begin(9600);
//configure the digital inputs:
pinMode(resetButton, INPUT);
pinMode(serveButton, INPUT);
}
void loop(){
//read the analog sensor:
leftValue = analogRead(leftSensor);
rightValue = analogRead(rightSensor);
//read the digital sensors:
reset = digitalRead(resetButton);
serve = digitalRead(serveButton);
//print the results:
Serial.print(leftValue, DEC);
Serial.print(",");
Serial.print(rightValue, DEC);
Serial.print(",");
Serial.print(reset, DEC);
Serial.print(",");
//"print the last sensor value with a printIn() so that
//each set of four readings prints on a line by itselft:
Serial.println(serve, DEC);
}
/*
// print the results:
Serial.print(leftValue, BYTE);
Serial.print(44, BYTE);
Serial.print(rightValue, BYTE);
Serial.print(44, BYTE);
Serial.print(reset,BYTE);
Serial.print(44, BYTE);
Serial.print(serve, BYTE);
Serial.print(13, BYTE);
Serial.print(10, BYTE);
}
*/
Thank you.
ps. is "Super-Sample" the correct terminology here, or should I be using another term ?
Justin.