Thursday, May 16, 2019

DIY VOICE HOME AUTOMATION USING ARDUINO AND ANDROID


DIY VOICE HOME AUTOMATION USING ARDUINO AND ANDROID

  • Circuit diagram




  • Code for Arduino UNO



//Edison Media
//Thejus B Oommen
String voice;
int RED = 2;
int GREEN = 3 ;
int BLUE = 4;
int YELLOW = 5;
void RedOn(){
digitalWrite (RED, LOW);
}
void RedOff(){
digitalWrite (RED, HIGH);
}
void GreenOn(){
digitalWrite (GREEN, LOW);
}
void GreenOff(){
digitalWrite (GREEN, HIGH);
}
void BlueOn(){
digitalWrite (BLUE, LOW);
}
void BlueOff(){
digitalWrite (BLUE, HIGH);
}
void YellowOn(){
digitalWrite (YELLOW, LOW);
}
void YellowOff(){
digitalWrite (YELLOW, HIGH);
}
void allon() {
digitalWrite (RED, LOW);
digitalWrite (GREEN, LOW);
digitalWrite (BLUE, LOW);
digitalWrite (YELLOW, LOW);
}
void alloff() {
digitalWrite (RED, HIGH);
digitalWrite (GREEN, HIGH);
digitalWrite (BLUE, HIGH);
digitalWrite (YELLOW, HIGH);
}
void setup() {
Serial.begin(9600);
pinMode(RED, OUTPUT);
pinMode(GREEN, OUTPUT);
pinMode(BLUE, OUTPUT);
pinMode(YELLOW, OUTPUT);
}
void loop() {
while(Serial.available()) {
delay(10);
char c=Serial.read();
if(c=='#')
{break; }
voice += c;
}
if (voice.length() > 0) {
Serial.println(voice);
if (voice == "on" || voice == "all")
{
allon() ;
}
else if (voice == "switch off" || voice=="switch off all")
{
alloff() ;
}
else if(voice =="tubelight" || voice =="tubelight on"){
RedOn();
}
else if(voice =="switch off tubelight" || voice =="tubelight off"){
RedOff();
}
else if(voice =="bedroom" || voice =="bedroom on"){
YellowOn();
}
else if( voice =="switch off bedroom" || voice =="bedroom off" ){
YellowOff();
}
else if(voice =="bulb" || voice =="bulb on"){
BlueOn();
}
else if(voice =="switch off bulb" || voice =="bulb off"){
BlueOff();
}
else if(voice =="ceiling fan" || voice =="ceiling fan on"){
GreenOn();
}
else if(voice =="switch off ceiling fan" || voice =="ceiling fan off"){
GreenOff();
}
voice="";
}
}





Please  subscribe our channel

Wednesday, May 1, 2019

Smart Dustbin using arduino

Circuit Diagram






Code for  Arduino


 //Edison Media
//Thejus B Oommen
#include <Servo.h>
Servo servo;   
int trigPin = 5; 
int echoPin = 6; 
int servoPin = 7;
int led= 10;
long duration, dist, average; 
long aver[3]; 


void setup() {     
    Serial.begin(9600);
    servo.attach(servoPin);
    pinMode(trigPin, OUTPUT);
    pinMode(echoPin, INPUT);
    servo.write(0);     
    delay(100);
    servo.detach();
}

void measure() {
 digitalWrite(10,HIGH);
digitalWrite(trigPin, LOW);
delayMicroseconds(5);
digitalWrite(trigPin, HIGH);
delayMicroseconds(15);
digitalWrite(trigPin, LOW);
pinMode(echoPin, INPUT);
duration = pulseIn(echoPin, HIGH);
dist = (duration/2) / 29.1; 
}
void loop() {
  for (int i=0;i<=2;i++) { 
    measure();             
   aver[i]=dist;         
    delay(10);           
  }
 dist=(aver[0]+aver[1]+aver[2])/3; 

if ( dist<50 ) {

 servo.attach(servoPin);
  delay(1);
 servo.write(0);
 delay(3000);     
 servo.write(150); 
 delay(1000);
 servo.detach();   
}
Serial.print(dist);
}

Friday, April 26, 2019

Automatic watering system for plants using arduino

Automatic watering system for plants                 using arduino




Circuit Diagram


Code For uno



int digitalSensor = 2;
int pumpPin = 8; //relay pin

void setup() {
  pinMode(digitalSensor, INPUT);
  pinMode(pumpPin, OUTPUT);
}

void loop() {
  if(digitalRead(digitalSensor) == HIGH){
    digitalWrite(pumpPin, LOW);
    delay(1000);
  }
  else{
    digitalWrite(pumpPin, HIGH);
  }
  delay(100); // 1hour
}