The following project gives you the ability to switch on your desktop computer over bluetooth.
The way this thing works is: You send a command over bluetooth (by pressing a key on your phone) and the electromagnet(attached on the arduino nano) connects two cables (that are acting as a switch).
The following circuitry support 5V and 12V electromagnets with the usage of PN222A transistor as shown
It is necessary to connect those two cables direct on the mainboard of your pc (where the power button connector is placed)
Another alternative could be a relay switch, but in this case I used an electromagnet.
Video on Youtube --> https://youtu.be/ChciUi8SHEA
Arduino Code under this line:
// voulios.blogspot.com (Technology Blog)
// Chrysovalantis Eleftheriadis
int button = 8;
int state; //State '1' activates power-on button, state '0' deactivates it.
int flag=0; //makes sure that the serial only prints once the state
void setup() {
pinMode (button, OUTPUT);
Serial.begin(9600);
}
void loop() {
//if some date is sent, reads it and saves in state
if(Serial.available() > 0){
state = Serial.read();
Serial.println(state);
flag=0;
}
if (state == '0') {
digitalWrite(button, LOW);
if(flag == 0){
Serial.println("Button is deactivated");
flag=1;
}
}
//Receives '1' from serial and activates the power button for 3 secs
else if (state == '1') {
digitalWrite(button, HIGH); //activates the button
delay(3000); //for three seconds
state='0'; //sets the state to '0' (for the next loop)
if(flag == 0){
Serial.println("Power Button has been pressed for 3 seconds");
flag=1;
}
}
}
The way this thing works is: You send a command over bluetooth (by pressing a key on your phone) and the electromagnet(attached on the arduino nano) connects two cables (that are acting as a switch).
The following circuitry support 5V and 12V electromagnets with the usage of PN222A transistor as shown
It is necessary to connect those two cables direct on the mainboard of your pc (where the power button connector is placed)
Another alternative could be a relay switch, but in this case I used an electromagnet.
Video on Youtube --> https://youtu.be/ChciUi8SHEA
Arduino Code under this line:
// voulios.blogspot.com (Technology Blog)
// Chrysovalantis Eleftheriadis
int button = 8;
int state; //State '1' activates power-on button, state '0' deactivates it.
int flag=0; //makes sure that the serial only prints once the state
void setup() {
pinMode (button, OUTPUT);
Serial.begin(9600);
}
void loop() {
//if some date is sent, reads it and saves in state
if(Serial.available() > 0){
state = Serial.read();
Serial.println(state);
flag=0;
}
if (state == '0') {
digitalWrite(button, LOW);
if(flag == 0){
Serial.println("Button is deactivated");
flag=1;
}
}
//Receives '1' from serial and activates the power button for 3 secs
else if (state == '1') {
digitalWrite(button, HIGH); //activates the button
delay(3000); //for three seconds
state='0'; //sets the state to '0' (for the next loop)
if(flag == 0){
Serial.println("Power Button has been pressed for 3 seconds");
flag=1;
}
}
}
No comments:
Post a Comment