Please help. I tried all the forums, no luck.
I am reading A(0) 0 to 5 volts. Y scale auto ranges where 5V at A(0) becomes middle of scale. And where 0V at A(0) becomes middle of scale.
/*
ReadAnalogVoltage
Center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
modified by yours truly, Dr. G
*/
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = sensorValue * (5.0 / 1050.0);
// print out the value of the potentiometer as an interger only:
//Trying to force Y not autoscale
Serial.print("0, "); //lower range sent to plotter
Serial.print("5, "); //lower range sent to plotter
float pi = 3.14;
int value = (int)pi;
Serial.print("voltage:");
Serial.println(voltage,0);
delay(200); // delay in between reads for stability
}
/*
ReadAnalogVoltage
Center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
modified by yours truly, Dr. G
*/
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = sensorValue * (5.0 / 1050.0);
// print out the value of the potentiometer as an interger only:
Serial.print("voltage:");
//Trying to force Y not autoscale
Serial.print("low:0, "); //lower range sent to plotter
Serial.print("high:5, "); //high range sent to plotter
Serial.println(voltage,0);
delay(200); // delay in between reads for stability
}
Thank you. I tired it and I am getting this error, and due to my ignorance dont know how to fix it.
This is the error message:
C:\Users\Acer_new\AppData\Local\Temp\ccqUf37O.ltrans0.ltrans.o: In function main': C:\Users\Acer_new\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/main.cpp:46: undefined reference to loop'
collect2.exe: error: ld returned 1 exit status
exit status 1
Compilation error: exit status 1
This is the sketch
/*
ReadAnalogVoltage
Center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
modified by yours truly, Dr. G
*/
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void serialPlotter() {
int Data1 = analogRead(A0);
int Data2 = 0;
int Data3 = 1023;
Serial.print("Trace1:");
Serial.print(Data1);
Serial.print(",");
Serial.print("Trace2:");
Serial.print(Data2);
Serial.print(",");
Serial.print("Trace3:");
Serial.println(Data3);
}
Thank you. Thank you. Thank you. Thank you. e infinity
Please one more question, how do I change the labels on the plot from Value 1, Value 2, Value 3 to Lower Voltage Threshold, Output Voltage and Upper Voltage Threshold?
/*
ReadAnalogVoltage
Center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
modified by yours truly, Dr. G
*/
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = sensorValue * (5.0 / 1050.0);
// print out the value of the potentiometer as an interger only:
//Serial.print("voltage:");
//Trying to force Y not autoscale
Serial.print("0, "); //lower range sent to plotter
Serial.print("5, "); //upper range sent to plotter
Serial.println(voltage,0);
delay(200); // delay in between reads for stability
}
I've done some testing.
It seems as though you can't have the label 'Lower Voltage Threshold' as three words.
The closest I could get was:
/*
ReadAnalogVoltage
Center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
modified by yours truly, Dr. G
*/
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = sensorValue * (5.0 / 1050.0);
// print out the value of the potentiometer as an interger only:
//Serial.print("voltage:");
//Trying to force Y not autoscale
Serial.print("Lower_Voltage_Threshold:0, "); //lower range sent to plotter
Serial.print("Upper_Voltage_Threshold:5, "); //upper range sent to plotter
Serial.print("Voltage:");
Serial.println(voltage);
delay(200); // delay in between reads for stability
}
JohnLincoln: You are the best. Without divulging details, this project will save lives. Again, thank you. I know I cannot pay you $$$; the lessons I learnt will help me teach others. Your giving will be multiplied. This Y axis autoscaling "problem" has been going on for about twelve years. Ditto making single digits.