@JohnRob I think this would be great. I plugged it into the circuit and refined it a bit, and then put our names on it. With your permission I will put together another sketch with the additional circuit schematic, etc, and make it public. If you would rather not, no problem too.
/*
Author: ado88 and JohnRob
Email: arduino.ado88@gmail.com
Date: Sept 11, 2021
Revision: Version 0.3.0 Beta
License: CC0 1.0 Universal License
Project: Arduino UNO #1
The Arduino Uno analog to digital converter compares an analog input (i.e. A0) to the 5v supply voltage.
It divides the 5V into 1024 steps called "counts" (0 to 1023). It compares the A0 voltage to the different steps and
returns the count of the step that most closely equals the input voltage on A0
Each step is 5V/1024 = 0.00488 volts.
The PWM (Pulse Width Modulated) outputs a 490 Hz (aka 490 times a second) waveform. The on time can be controlled in 255 steps
0 = not on time
128 = on 50% of the time
255 = on 100% of the time
In the code below, the processor will "measure" the voltage (by converting it to counts, see above)
At very low counts, the RED light will be dominant and the GREEN off. As the voltage on the pot increases,
the RED will start to dim and the GREEN will increase in brightness.
When the pot is in the center, both LED will be on the same brightness, creating an orange color.
*/
#define RED 9 // Set red output - may need to switch LED or numbering within program
#define GREEN 10 // Set green output - #define does not use up memory resources on the Uno
#define V_POT 0 // Set voltage input pin (A0)
void setup() {
pinMode(RED, OUTPUT); //Set as outputs for LEDs
pinMode(GREEN, OUTPUT);
analogWrite(RED, 0); // Initializes red/green LED to off (LOW) (0)
analogWrite(GREEN, 0);
Serial.begin(9600);
}
void loop() {
int InputVoltage = analogRead(V_POT);
int pwmOut = 0.25 * InputVoltage; //int is a whole number variable type so it will automatically round to a whole number
analogWrite(RED, (255 - pwmOut)); // When pwmOut is at max, RED is at zero
analogWrite(GREEN, pwmOut); // When pwmOut is at max, GREEN is at full brightness (255)
Serial.println(pwmOut);
delay(100); // delay in milliSeconds. Makes the program respond more slowly to changes in POT voltage.
}