|
楼主 |
发表于 2018-2-8 13:28
|
显示全部楼层
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
float temp;
void setup()
{
Serial.begin(9600);
lcd.begin(16, 2);
}
void loop()
{
int V1 = analogRead(A0);
float vol = map(V1,0.0,1023.0,0.0,5.0);
if (vol == temp)
{
temp = vol;
}
else
{
Serial.print(vol);
Serial.println(" V");
lcd.setCursor(5, 0);
lcd.print(vol);
lcd.setCursor(10, 0);
lcd.print("V");
temp = vol;
delay(1000);
}
} |
|