Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <LiquidCrystal.h>
- int pin_VIB = 22; ////Vibrator Set
- int pin_CDS = A0;
- int pin_LCD_DATA[8] = {A8,A9,A10,A11,A12,A13,A14,A15};
- int pin_LCD_CTRL[3] = {A5,A6,A7};
- LiquidCrystal lcd(A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15);
- void setup() {
- pinMode(pin_CDS, INPUT);
- pinMode(pin_VIB, OUTPUT); //Vibrator Set
- lcd.begin(16,2);
- lcd.print("ADC Data :");
- lcd.setCursor(0, 1);
- lcd.print("Volt : [V]");
- }
- void loop() {
- uint16_t da = analogRead(pin_CDS);
- float voltage = (float)da * 5 /1023;
- lcd.setCursor(11, 0);
- if(da<1000){lcd.print(" ");}
- if(da<100){lcd.print(" ");}
- if(da<10){lcd.print(" ");}
- lcd.print(da);
- lcd.setCursor(8, 1);
- lcd.print(voltage);
- //v Vibrator Set
- if(voltage <= 2)
- {
- digitalWrite(pin_VIB,HIGH);
- delay(500);
- }
- else
- {
- digitalWrite(pin_VIB,LOW);
- delay(500);
- }
- //^
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement