Printing on screen analogue values

As a rank beginner with the Arduino processor my first attempt at running an Analogue program was the "arduino.cc/en/Tutorial/AnalogInput" the system works but I would like to be able to read the sensorValue as the pot resistance value is altered. Can anyone advise me in simple terms how this is possible please?

See the arduino reference for information on Serial.print

 int sensorPin = 0;    // select the input pin for the potentiometer
 int sensorValue = 0;  // variable to store the value coming from the sensor

 void setup() {
   Serial.begin(9600);
 }

 void loop() {
   // read the value from the sensor:
   sensorValue = analogRead(sensorPin);    
   Serial.println(sensorValue);
   delay(100); // the number of milliseconds between readings                 
 }

Also, make sure you know where the "serial monitor" is on the IDE, and that you set the same bit rate as on the Arduino.

I think he's looking to print the Value only when it changes. I looked into this same thing when I started, but have been playing more with LCDs than anything.. still kind of curious myself.

I think he's looking to print the Value only when it changes.

Try this adjusted code:

 int sensorPin = 0;    // select the input pin for the potentiometer
 int sensorValue = 0;  // variable to store the value coming from the sensor
 int sensorValuePrev = 0;  // variable to store the previous value of the sensor

 void setup() {
   Serial.begin(9600);
 }

 void loop() {
   // read the value from the sensor:
   sensorValue = analogRead(sensorPin);    
   if (sensorValue != sensorValuePrev) {
     Serial.println(sensorValue);
     sensorValuePrev = sensorValue;
   }
   delay(100); // the number of milliseconds between readings                
 }

Yes I am trying to get an analogue value on the screen.
I cut and pasted your program to the processor but still no numeretical value, just a whole block of squares appear when I trigger the sreial monitor button.

Thank you all for your assistance I hadn't set the baud rate for monitor.

One thing you might consider is setting up a bit of a buffer zone on the changing values. If you do not then the slightest twitch will cause the arduino to output. Was not sure if you realized.

How do you go about creating a "Buffer Zone" The best I've done is only display if it changes.. but even with a twitch.. is there anyway to make it display only if it changes say.. 20?

Setting up a buffer zone is an excellent idea for a real-world application, so thanks for taking us to that next level, Confused8737.

Replace the if statement with these two lines:

   ...
   int sensorChange = sensorValue - sensorValuePrev;
   if (abs(sensorChange) >= 20) {
   ...

That uses the "absolute value" function to trigger the print when the value either goes up or down by 20 or more.

Sorry for the need for two lines, but the abs() function seems to be sensitive to anything except a number. (See the warning at http://arduino.cc/en/Reference/Abs.)

Also, I would prefer to declare the int sensorChange with the other declarations, but I'm trying to keep the changes minimal and understandable in this post for the self-proclaimed "rank beginner" original poster. (Been there, done that, can appreciate the feeling. :slight_smile: )

Hope this is clear enough. I prefer not to re-post the whole thing so you can understand the effect of the change, but I will expain further if you need me to.

Now I understand this. I am really thank full to you for this valuable advice.
Ashley Madison