Domotica

Para domotizar o automatizar una casa y activar dispositivos con el celular o móvil se requieren dos programas:

Domotica

  • El programa que lleva el arduino:

#include <Servo.h>

Servo garage;
int pos = 0;

int sala = 9;
int estancia = 10;
int recamara = 11;
int abanico= 12;
//int garage = 13;

String readString;

void setup() {
{
garage.attach(13);
}
Serial.begin(9600);
pinMode(sala, OUTPUT);
pinMode(estancia, OUTPUT);
pinMode(recamara, OUTPUT);
pinMode(abanico, OUTPUT);
//pinMode(garage, OUTPUT);
}

void loop() {
while (Serial.available()) {
delay(3);
char c = Serial.read();
readString += c;
}
if (readString.length() >0) {
Serial.println(readString);
if (readString == “salaon”)
{
digitalWrite(sala, HIGH);
}
if (readString == “salaoff”)
{
digitalWrite(sala, LOW);
}

if (readString == “estanciaon”)
{
digitalWrite(estancia, HIGH);
}
if (readString == “estanciaoff”)
{
digitalWrite(estancia, LOW);
}

if (readString == “recon”)
{
digitalWrite(recamara, HIGH);
}
if (readString == “recoff”)
{
digitalWrite(recamara, LOW);
}

if (readString == “abanicoon”)
{
digitalWrite(abanico, HIGH);
}
if (readString == “abanicooff”)
{
digitalWrite(abanico, LOW);
}

if (readString == “garageon”)
{
for(pos = 0; pos < 80; pos += 1)
{
garage.write(pos);
delay(15);
}
//digitalWrite(garage, HIGH);

}
if (readString == “garageoff”)
{
for(pos = 80; pos>=1; pos-=1)
{
garage.write(pos);
delay(15);
} //digitalWrite(garage, LOW);
}

readString=””;
}
}