Tasks Ca

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

TRAFFIC SIGNAL

Code
#include <LiquidCrystal.h> delay(3000); }
LiquidCrystal lcd(12, 11, 5, 4, } else if(i==0)
3, 2); else if(i==0) {
void setup() { digitalWrite(10, HIGH);
{ digitalWrite(10, HIGH); digitalWrite(13, LOW);
pinMode(13, OUTPUT); digitalWrite(13, LOW); digitalWrite(9, LOW);
pinMode(10, OUTPUT); digitalWrite(9, LOW); digitalWrite(8, LOW);
pinMode(9, OUTPUT); digitalWrite(8, LOW); digitalWrite(6, LOW);
pinMode(8, OUTPUT); digitalWrite(6, LOW); digitalWrite(7, HIGH);
pinMode(7, OUTPUT); digitalWrite(7, HIGH); delay(1000);
pinMode(6, OUTPUT); delay(2000); }
lcd.begin(16, 2); lcd.clear(); lcd.clear();
} } }
void loop() { } }
int i; for(i=10; i>=0; i--)
for(i=10; i>=0; i--) {
{ lcd.clear(); lcd.print(i);
lcd.print(i); if (i <=10 && i>0)
if (i <=10 && i>0) {
{ digitalWrite(10, LOW);
digitalWrite(13, HIGH); digitalWrite(13, LOW);
digitalWrite(10, LOW); digitalWrite(9, HIGH);
digitalWrite(9, LOW); digitalWrite(8, HIGH);
digitalWrite(8, LOW); digitalWrite(7, LOW);
digitalWrite(7, LOW); digitalWrite(6, LOW);
digitalWrite(6, HIGH); delay(1000);
GAS DETECTOR

CODE
#include <LiquidCrystal.h> digitalWrite(LED_Danger,
const int rs = 12, en = 11, d4 LOW);
= 5, d5 = 4, d6 = 3, d7 = 2; digitalWrite(LED_Safe,
LiquidCrystal lcd(rs, en, d4, HIGH);
d5, d6, d7);
int alarm=8; while(gas_data>350){
int gas_pin= 0; gas_data=
float gas_data=0; analogRead(gas_pin);
int LED_Danger=9; digitalWrite(alarm, HIGH);
int LED_Safe= 10; digitalWrite(LED_Danger,
void setup() HIGH);
{ digitalWrite(LED_Safe,
lcd.begin(16, 2); LOW);
} lcd.setCursor(0, 0);
lcd.print("Mr Gas
void loop() Detector");
{ lcd.setCursor(0, 1);
gas_data= lcd.print("!!!WARNING!!!");
analogRead(gas_pin); delay(200);
lcd.setCursor(0, 0);
lcd.print("Mr Gas }
Detector"); delay(200);
lcd.setCursor(0, 1);
lcd.print("Gas : "); }
lcd.setCursor(6, 1);
lcd.print(gas_data);
digitalWrite(alarm, LOW);
TEMPRATURE DETECTOR

CODE

// include the library code:


#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
pinMode(A0,INPUT);
analogReference(INTERNAL);
Serial.begin(9600);
}
void loop() {
// set the cursor to column 0, line 1
int reading = analogRead(A0);
float tempc = reading/9.31;
float tempf = (tempc * 9/5) + 32;
Serial.println(tempc);
delay(1000);
// print the number of seconds since reset:
lcd.setCursor(0, 0);
lcd.print("F ");
lcd.print(tempf);
lcd.setCursor(0, 1);
lcd.print("C ");
lcd.print(tempc);
delay(2000);
lcd.clear();
}
OBJECT DETECTOR

CODE
#include <LiquidCrystal.h> lcd.setCursor(0, 0); lcd.setCursor(6,0);
// initialize the library with digitalWrite(trigpin,LOW); distanceInch = distanceInch
the numbers of the interface delayMicroseconds(2); / 0.39;
pins digitalWrite(trigpin,HIGH); lcd.print(distanceInch);
LiquidCrystal lcd(12, 11, 5, 4, delayMicroseconds(10); delay(500);
3, 2); digitalWrite(trigpin,LOW); lcd.setCursor(0,1);
distanceInch =
#define trigpin 8 duration = distanceInch * 0.083;
#define echopin 9 pulseIn(echopin,HIGH); lcd.print(distanceInch);
#define buzzer 10 digitalWrite(buzzer,LOW); delay(500);
long duration; distanceInch = duration * lcd.setCursor(6,1);
float distanceInch; 0.0133 / 2; distanceInch =
int timer; if (distanceInch < 15) distanceInch /25.4;
{ lcd.print(distanceInch);
void setup() { lcd.clear(); }
// set up the LCD's number digitalWrite(buzzer,HIGH);
of columns and rows: digitalWrite(13,HIGH); timer = distanceInch * 10;
lcd.begin(16, 2); digitalWrite(7,LOW);
lcd.print("Warning"); delay(1000);
pinMode(trigpin,OUTPUT); }
pinMode(echopin,INPUT); else delay(timer);
pinMode(buzzer,OUTPUT); {
pinMode(13,OUTPUT); digitalWrite(buzzer,LOW); }
pinMode(7,OUTPUT); digitalWrite(7,HIGH);
} digitalWrite(13,LOW);
lcd.print(distanceInch);
void loop() { delay(500);
IR REMOTE

CODE
#include <LiquidCrystal.h> int lcdvalue; }
#include <IRremote.h> if(irrecv.decode(&results)) else
const int recvpin=7; {unsigned int value = {digitalWrite(led3,HIGH);
int led1 =9; results.value; itsONled[1] = 1;
int led2 =13; lcdvalue = value; }
int led3 =8; switch(value) break;
int led4 =6; { case code1: case code4:
int led5 =10; if(itsONled[1] == 1) if(itsONled[1] == 1)
int itsONled[] ={0,0}; { digitalWrite(led1,LOW); {digitalWrite(led4,LOW);
#define code1 2295 itsONled[1] = 0; itsONled[1] = 0;
#define code2 34935 } }
#define code3 18615 else else
#define code4 10455 { digitalWrite(led1,HIGH); {digitalWrite(led4,HIGH);
#define code5 43095 itsONled[1] = 1; itsONled[1] = 1;
IRrecv irrecv(recvpin); } }break;
decode_results results; break; case code5:
LiquidCrystal lcd(12, 11, 5, 4, case code2: if(itsONled[1] == 1)
3, 2); if(itsONled[1] == 1) {digitalWrite(led5,LOW);
void setup() { {digitalWrite(led2,LOW); itsONled[1] = 0;
lcd.begin(16, 2); itsONled[1] = 0; }else
Serial.begin(9600); } { digitalWrite(led5,HIGH);
irrecv.enableIRIn(); else itsONled[1] = 1;
pinMode(led1,OUTPUT); { digitalWrite(led2,HIGH); }
pinMode(led2,OUTPUT); itsONled[1] = 1; break;
pinMode(led3,OUTPUT); } }Serial.println(value);
pinMode(led4,OUTPUT); break; irrecv.resume();
pinMode(led5,OUTPUT); case code3: } lcd.print(lcdvalue);
} if(itsONled[1] == 1) delay(1000);
void loop() { { digitalWrite(led3,LOW); lcd.clear();
lcd.setCursor(0, 1); itsONled[1] = 0; }

You might also like