// Pin definitions
const int pwmPin = 5; // PWM output pin
const int voltageSensePin = A0; // Voltage sensing pin
// Functions
void setup() {
pinMode(pwmPin, OUTPUT); // Set the PWM pin as an output
pinMode(voltageSensePin, INPUT); // Set the voltage sensing pin as an input
Serial.begin(9600); // Initialize serial communication for debugging
}
void loop() {
int sensorValue = analogRead(voltageSensePin); // Read the analog input
float Vin = sensorValue * (5.0 / 1023.0); // Convert the analog reading to voltage
float Vout = Vin * 12.0 / 5.0; // Calculate the output voltage
// Debugging
Serial.println(sensorValue);
delay(500);
}