Rơle hoạt động thấp
Sơ đồ nối dây
Arduino với Bluetooth HC05
Arduino ---------- Bluetooth HC05
Tx ---------------- Rx
Rx ---------------- Tx
---------------- 5V 5V
--------------- GND GND
Arduino với Rơ le 4 Chanel
Rơle ---------------
2 ----------------- Rơle 1
3 ----------------- Rơle 2
4 ----------------- Rơ le 3
5 ----------------- Rơle 4
Arduino Sketh
dữ liệu Bluetooth;
void setup () {
Nối tiếp.begin (9600);
pinMode (2, ĐẦU RA); // Relay 1
pinMode (3, ĐẦU RA); // Rơle 2
pinMode (4, ĐẦU RA); // Rơ le 3
pinMode (5, OUTPUT); // Rơ le 4
digitalWrite (2, CAO);
kỹ thuật sốWrite (3, CAO);
kỹ thuật sốWrite (4, CAO);
digitalWrite (5, CAO);
}
void loop () {
if (Serial.available ()) {
DataBluetooth = Serial.read ();
// Bật Rơle 1
if (DataBluetooth == 'A') {
kỹ thuật sốWrite (2, THẤP);
}
// Tắt rơle 1
if (Dữ liệu Bluetooth == 'B') {
digitalWrite (2, CAO);
}
// Bật Rơ le 2
if (DataBluetooth == 'C') {
digitalWrite (3, LOW);
}
// Tắt Rơ le 2
if (DataBluetooth == 'D') {
kỹ thuật sốWrite (3, CAO);
}
// Bật Relay 3
if (DataBluetooth == 'D') {
kỹ thuật sốWrite (4, THẤP);
}
// Tắt Rơ le 3
if (DataBluetooth == 'E') {
kỹ thuật sốWrite (4, CAO);
}
// Bật Rơ le 4
if (DataBluetooth == 'F') {
digitalWrite (5 LOW);
}
// Tắt Relay 4
if (DataBluetooth == 'G') {
kỹ thuật sốWrite (5, CAO);
}
}
}
Kendali Relay 4 Chanel Arduino