Store maximum analog read value and print it + oscillation issue

Hello everyone,

In my code, attached, I'm programming three string pots to measure deflection for for my school project. This is my first time programming so any help will be much appreciated.

My problem is that I need to store the three maximum values from all three pots and display them. Display organization doesn't really matter at this point. All I need is to know how to keep track of maximum values. It seems very simple, but I couldn't find a straight answer.

My other issue is that the values of the analog read oscillates between two values. Are there any suggestions on how to fix that?

I called the manufacturer of the string pots and they recommended using a regulated power source like a 9v wall plug adapter. Which helped reduce the oscillation significantly but didn't stop it. I've also tried putting a 10 microF capacitor in parallel with the pots, which also didn't help.

PLEASE HELP!!!

StringPot2.ino (1.41 KB)

nedster:
PLEASE HELP!!!

PLEASE GOOGLE: hysteresis C++ code !!!

notice the first result

you can test for a maximum so

void loop() {
  static float Pot1max=0.0;
  float Pot1 = analogRead(PotPin); // this grabs the data form the pin
  if(Pot1 > Pot1max) Pot1max=Pot1;

horace:
you can test for a maximum so

void loop() {

static float Pot1max=0.0;
  float Pot1 = analogRead(PotPin); // this grabs the data form the pin
  if(Pot1 > Pot1max) Pot1max=Pot1;

hmmm...

analogRead() returns an integer on my arduino...

maybe I have a metric Arduino

All I need is to know how to keep track of maximum values.

For each pot declare a variable to hold the maximum and set them to zero. Each time you read a value compare it with the value of the variable. If it is greater than the value of the variable then set the variable to the new maximum value.

I'm programming three string pots

I was going to ask what a string pot was, but I googled the term first. So, now I want to know how you are programming a device that does not incorporate a microcontroller.