Microcontroller 20
วัดไฟด้วย Arduino
อุปกรณ์
- Arduino UNO
- 16 x 2 LCD Display
- 10KΩ POT
- 100KΩ
- 10KΩ
- Connecting Wires
Circuit Diagram
Code 1
#include "LiquidCrystal.h"
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
float voltage = 0.0;
float temp=0.0;
int analog_value;
void setup()
{
lcd.begin(16, 2);
lcd.setCursor (0,0);
lcd.print(" Arduino based ");
lcd.setCursor(0,1);
lcd.print("Digital Voltmeter");
delay(2000);
}
void loop()
{
analog_value = analogRead(A0);
temp = (analog_value * 5.0) / 1024.0;
voltage = temp/(0.0909);
if (voltage < 0.1)
{
voltage=0.0;
}
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Voltage= ");
lcd.print(voltage);
lcd.setCursor(13,1);
lcd.print("V");
delay(30);
}
Code 2
#include "LiquidCrystal.h"
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
float voltage = 0.0;
float temp=0.0;
int analog_value;
void setup()
{
lcd.begin(16, 2);
lcd.setCursor (0,0);
lcd.print(" Arduino based ");
lcd.setCursor(0,1);
lcd.print("Digital Voltmeter");
delay(2000);
}
void loop()
{
analog_value = analogRead(A0);
voltage = (analog_value * 5.0) / 1024.0;
if (voltage < 0.1)
{
voltage=0.0;
}
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Voltage= ");
lcd.print(voltage);
lcd.setCursor(13,1);
lcd.print("V");
delay(30);
}
ความคิดเห็น
แสดงความคิดเห็น