Saturday, June 25, 2022

tinkercad ADC


#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd1(0x20,16,2);

void setup()
{
  lcd1.init();
  lcd1.clear(); 
  lcd1.backlight(); 
}

void loop()
{
  float ADC_A0 = analogRead(A0);
  float V_A0 = ADC_A0 * 5 / 1024;
  
  float ADC_A1 = analogRead(A1);
  float V_A1 = ADC_A1 * 5 / 1024;
  
  lcd1.setCursor(0,0);
  lcd1.print("A0  ");
  lcd1.print(V_A0, 4);
  
  lcd1.setCursor(0,1);
  lcd1.print("A1  ");
  lcd1.print(V_A1, 4);
  
  delay(500);
}

reference:

No comments:

Post a Comment