Hi everyone!!
I'm making a project for high school, I have to turn on and off some stuff through an Android app that I designed.
4 led strips
1 servomotor
1 fan
I can already turn on and turn off the servomotor with Android, but the led strip and the fan that I'm using are of 12V both. I've got an external source of 12V, I've checked a lot of videos about how to turn them on and off via bluetooth , but it's been impossible
Some videos said that I needed to buy a transistor "TIP122" so I can control high currents, I bought the component, and I've tried a lot of schematic diagrams but nothing works... Here's the code by the way. Sorry about the language, I translated most of the stuff into English, so you can see where everything is.
#include <Servo.h>
Servo servo1;
void setup ()
{
servo1.attach(3); // DOOR
pinMode(2,OUTPUT); // LIGHTS
pinMode(5,OUTPUT); // FAN
Serial1.begin(9600);
}
void loop() {
while (Serial1.available())
{
char dato=Serial1.read();
switch(dato)
{
case '1':
servo1.write(0);
delay(500);
Serial1.println("CLOSE DOOR");
digitalWrite(5,HIGH);
Serial1.println("FAN ON");
digitalWrite(2,HIGH);
Serial1.print("LIGHTS ON"); // Sala
break;
{
case '2':
digitalWrite(4,HIGH);
Serial1.print("LIGHTS OFF"); // Cocina
break;
{
case '3':
digitalWrite(6,HIGH);
Serial1.print("LIGHTS OFF"); // Baño
break;
{
case '4':
digitalWrite(7,HIGH);
Serial1.print("LIGHTS OFF"); // Cuarto
break;
{
case '5':
digitalWrite(8,HIGH);
Serial1.print("LIGHTS OFF"); //Garage
break;
{
case '6':
digitalWrite(4,LOW);
Serial1.print("LIGHTS OFF"); // Cocina
break;
{
case '7':
digitalWrite(6,LOW);
Serial1.print("LIGHTS OFF"); // Baño
break;
{
case '8':
digitalWrite(7,LOW);
Serial1.print("LIGHTS OFF"); // Cuarto
break;
{
case '9':
digitalWrite(8,LOW);
Serial1.print("LIGHTS OFF"); //Garage
break;
{
case '0':
servo1.write(90); // Abrir la puerta
delay(500);
Serial1.println("OPEN DOOR");
break;
{
case 'a':
digitalWrite(2,LOW);
Serial1.print("Turn Off Lights"); // Sala
{
case 'b':
digitalWrite(5,LOW);
Serial.print("Turn Off Fan"); // Turn off Fan
break;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
P.S: I'm using Arduino Leonardo by the way