// C++ code
//
#include <LiquidCrystal_I2C.h>
int ldr_light = 0;
int darkness = 0;
LiquidCrystal_I2C lcd_2(0x27, 16, 2);
void setup()
{
  lcd_2.init();
  lcd_2.clear();         
  lcd_2.backlight();
  pinMode(A0, INPUT);
  pinMode(7, OUTPUT);
  darkness = 650;
}
void loop()
{
  ldr_light = analogRead(A0);
  lcd_2.setCursor(1,0);
  lcd_2.print("Is it dark ?");
  lcd_2.setCursor(1,1);
  lcd_2.print("darkness=");
  lcd_2.print(ldr_light);
  if (ldr_light < darkness) {
    digitalWrite(7, HIGH);
  } else {
    digitalWrite(7, LOW);
  }
  delay(1000); // Wait for 1000 millisecond(s)
  lcd_2.clear();
}

Δεν υπάρχουν σχόλια:
Δημοσίευση σχολίου