Some of you must have heard from ChatGPT, which is old hat.
The new kid on the block is Codey, the programmers alter ego of ChatGPT.
I asked Codey:
"Make code for an ESP32 to measure an analog voltage."
"Sure", Codey said:
Code: Select all
const int analogInPin = 34; // Pin for the analog input
void setup() {
Serial.begin(9600); // Start the serial communication with the computer
}
void loop() {
int sensorValue = analogRead(analogInPin); // Read analog voltage from pin
float voltage = sensorValue * (3.3 / 4095.0); // Convert the ADC value to voltage
Serial.println(voltage); // Send the measured voltage to the serial monitor
delay(1000); // Wait for 1 second before reading again
}
Of course, you can modify this code to fit your needs. Let me know if you have any further questions!
Jan