MUstar

IoT 아두이노 0616 - V/R샘플

Jun 15th, 2017
67
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <LiquidCrystal.h>
  2. int pin_VR = A1;
  3. int pin_LCD_DATA[8] = {A8,A9,A10,A11,A12,A13,A14,A15};
  4. int pin_LCD_CTRL[3] = {A5,A6,A7};
  5. LiquidCrystal lcd(A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15);
  6.  
  7.  
  8. void setup() {
  9.   pinMode(pin_VR, INPUT);
  10.   lcd.begin(16,2);
  11.   lcd.print("ADC Data :");
  12.   lcd.setCursor(0, 1);
  13.   lcd.print("Volt :      [V]");
  14.  
  15. }
  16.  
  17. void loop() {
  18.   uint16_t da = analogRead(pin_VR);
  19.   float voltage = (float)da * 5 /1023;
  20.   int vid_v = (int)voltage;
  21.   lcd.setCursor(11, 0);
  22.   if(da<1000){lcd.print(" ");}
  23.   if(da<100){lcd.print(" ");}
  24.   if(da<10){lcd.print(" ");}
  25.   lcd.print(da);
  26.   lcd.setCursor(8, 1);
  27.   lcd.print(voltage);
  28.   delay(500);
  29. }
RAW Paste Data