'''MPU 6050 Acclero and gyro -> Integrated sensor with 3-axis accelerometer, 3-axis gyroscope and a
temperature sensor with I2C interface.'''
from machine import Pin, ADC
import time
# Define the ADC pin
adc_pin = Pin(32) # Use GPIO 32 for ADC
# Create an ADC object
adc = ADC(adc_pin)
# Set the attenuation level to 11dB (for ESP32)
adc.atten(ADC.ATTN_11DB)
while True:
# Read the ADC value
adc_value = adc.read()
# Convert ADC value to voltage (assuming 3.3V reference voltage)
voltage = adc_value * 3.3 / 4095
# Print the ADC value and corresponding voltage
print("ADC Value:", adc_value)
print("Voltage:", voltage, "V")
# Wait for a short duration before taking the next reading
time.sleep(1)