// NR1 - LCD - Tekst ekraanil
#include
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
lcd.begin(16, 2);
lcd.print("Hello, world!");
}
void loop() {
}
// NR2 - vilkumine, koodi täiendamine
void loop() {
lcd.print("Hello, world!");
delay(500);
lcd.clear();
delay(500);
}
// NR3 - Scrolling
#include
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
lcd.begin(16, 2);
lcd.print("What's Up? How are you doing?");
}
void loop() {
lcd.scrollDisplayLeft();
delay(250);
}
// NR4 - Temperatuuri andur
#include
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
lcd.begin(16, 2);
}
void loop() {
int reading = analogRead(A0);
float voltage = reading * 5.0;
voltage /= 1024.0;
float temperatureC = (voltage - 0.5) * 100;
lcd.setCursor(0,0);
lcd.clear();
lcd.print("degrees: ");
lcd.print(temperatureC);
lcd.print("C");
delay(500);
}
//NR5 - Temperatuuri ja niiskuse andur
#include
#include
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
dht DHT;
#define DHT11_PIN 7
void setup(){
lcd.begin(16, 2);
}
void loop(){
int chk = DHT.read11(DHT11_PIN);
lcd.setCursor(0,0);
lcd.print("Temp: ");
lcd.print(DHT.temperature);
lcd.print((char)223);
lcd.print("C");
lcd.setCursor(0,1);
lcd.print("Humidity: ");
lcd.print(DHT.humidity);
lcd.print("%");
delay(1000);
}
// NR6 - Valgusandur
#include
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
lcd.begin(16, 2);
Serial.begin(9600);
}
void loop() {
int valgusS = analogRead(A0);
int valgus= 1023-valgusS;
lcd.setCursor(0,0);
lcd.clear();
lcd.print("Valgus: ");
lcd.print(valgus);
lcd.print("");
Serial.println(valgus);
delay(500);
}
//NR7 - leegisensor
#include
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int flamePin = 0 ;
#define buzzerPin 10
void setup() {
Serial.begin(9600);
lcd.begin(16, 2);
pinMode(buzzerPin,OUTPUT);
pinMode(flamePin,INPUT);
lcd.setCursor(0, 0);
Serial.begin(9600);
}
void loop() {
int Flame = analogRead(flamePin);
if (Flame>=500)
{
digitalWrite(buzzerPin,HIGH);
lcd.setCursor(0, 0);
lcd.print(" Flame : ");
lcd.print("Flame");
lcd.setCursor(0, 1);
lcd.print(" is Detected");
Serial.print(Flame);
Serial.print("\t");
Serial.print("Flame is Detected");
}
else
{
digitalWrite(buzzerPin,LOW);
lcd.setCursor(0, 0);
lcd.print("Flame : ");
lcd.print("No Flame");
Serial.print(Flame);
Serial.print("\t");
Serial.println("No Flame");
Serial.println(Flame);
}
delay(300);
lcd.clear();
}