I see that you have compiled it and are getting serial data out. That's 80% of the effort.
That version I sent you was saved more than a year ago. I chose it because it didn't have
a lot of extraneous stuff in it. Obviously later versions were corrected. Now we are adding
most of it back in. All variables have to be declared at the beginning. int indicates it
is a standard integer and you assign an initial value to it. Integers an be up to + or -
32K. Remember that that when the variable will be multiplied. The format is as follows.
int pot = 0; // raw A/D pot voltage
The semi colon (
indicates the end of every statement. Math follows the MiDAS rule in an
equation.Multiplication is done first, then division, adding and last subtracting unless
parentheses are used. Look in the case of calculating PW percentage. (you should add this)
Serial.print(" "); // create space between last data
Serial.print(PWM3 * 100 / 255); // print percentage output value
Serial.println("% power"); // identify variable and do line feed
This will give values between 0-100. If the following was done.
((PWM3/255) * 100) The only two answers would be 0 and 100.
That is integer math, a calculator wouldn't care. Note the println at the end. That creates
a carriage return at the end. You are old enough to remember a typewriter. If you don't
remove the ln from the previous print statement, the % printing will be on a separate line.
The (" ") creates a space. Otherwise the two numbers would run together.
I also changed the code to the following.
Serial.print("voltage is "); // identify variable
Serial.print((float)panel / 10); // print actual panel voltage
// float formats to two decimal places
(float) changes the printing format to two decimal places, so what is displayed is 124.30
instead of 1243. The math is still integer so it is faster. This can also be done to setpoint.
I take the simplistic form of code to display on this site. I add spaces for readability and
don't use shortcuts like ++ to increment up. This helps it look more like English and not so
intimidating. If you keep this format it will be easier to understand when it is looked at a
year later.