Arduino Bluetooth Automation

Arduino Bluetooth Automation

  • Последняя версия
  • RAVIVARMAN RAJENDIRAN

Управлять пятью устройствами, подключенными к контроллерам, используя Bluetooth, используя это приложение

Об этом приложении

Arduino Bluetooth Automation используется для управления пятью устройствами, подключенными к контроллерам, таким как Arduino или любая другая беспроводная беспроводная связь с использованием модуля Bluetooth.
Когда каждая кнопка нажата, соответствующее значение номера кнопки будет отправлено вместе со значениями включения/выключения. Например, если кнопку переключения на включении 1, то будет отправлено 11, если вы выключите кнопку 1, тогда будет отправлено 10. Другие значения приведены ниже.
Переключатель 1 включен - 11 Переключатель 1 выключен - 10
Переключение 2 включено - 21 Переключатель 1 выключен - 20
Переключатель 3 включения - 31 Переключатель 1 выключен - 30
Переключение 4 включено - 41 Переключатель 1 выключен - 40
Переключатель 5 включен - 51 Переключатель 1 выключен - 50

Пример кода Arduino с ЖК -дисплеев приведен ниже:

#include "arduino.h"

#включают
#включают
#включают

const int output1 = 6, output2 = 7, output3 = 8, output4 = 9;
const int input1 = 14, input2 = 15;

Строковые данные;

Liquidcrystal LCD (12, 11, 5, 4, 3, 2);
Softwareserial MISERIAL (9, 10);
Simpletimer Timer;

void repeatme () {
lcd.setcursor (0, 1);
if (DigitalRead (Input1) и DigitalRead (Input2)) {
myserial.print ("00");
lcd.print (”in1: no, in2: no»);
}
else if (! DigitalRead (Input1) и DigitalRead (Input2)) {
myserial.print ("10");
lcd.print (”In1: да, in2: no»);

}
else if (DigitalRead (input1) и! DigitalRead (input2)) {
myserial.print (”01”);
lcd.print (”in1: no, in2: yes»);

}
else if (! DigitalRead (Input1) и! DigitalRead (Input2)) {
myserial.print ("11");
lcd.print (”in1: да, in2: да»);

}
}

void setup () {
Serial.begin (9600);
myserial.begin (9600);
Timer.SetInterval (5000, RepeatMe);

Serial.println (”Система началась ....»);
pinmode (output1, output);
pinmode (output2, output);
pinmode (output3, output);
pinmode (output4, output);

pinmode (input1, input_pullup);
pinmode (input2, input_pullup);

Lcd.begin (16, 2);
lcd.setcursor (0, 0);
lcd.print («Система Bluetooth»);
}

void loop () {
timer.run ();
serialevent ();
}

void serialevent () {
while (myserial.vailable ()) {
задержка (10);
char c = myserial.read ();
if (c == '#') {
Serial.println (data);
ломать;
}
данные += c; // shorthand для data = data + c
}
if (data.length () и gt; 0) {
if (data == ”10”) {
DigitalWrite (output1, low);
lcd.setcursor (0, 0); lcd.print (”1: n,”);
} else if (data == ”11”) {
DigitalWrite (output1, High);
lcd.setcursor (0, 0); lcd.print (”1: y,”);
} else if (data == ”20”) {
DigitalWrite (output2, low);
lcd.setcursor (4, 0); lcd.print (”2: n,”);
} else if (data == ”21”) {
DigitalWrite (output2, High);
lcd.setcursor (4, 0); lcd.print (”2: y,”);
} else if (data == ”30”) {
DigitalWrite (output3, low);
lcd.setcursor (8, 0); lcd.print (”3: n,”);
} else if (data == ”31”) {
DigitalWrite (output3, High);
lcd.setcursor (8, 0); lcd.print (”3: y,”);
} else if (data == ”40”) {
DigitalWrite (output4, low);
lcd.setcursor (12, 0); lcd.print (”4: n.”);
} else if (data == ”41”) {
DigitalWrite (output4, High);
lcd.setcursor (12, 0); lcd.print (”4: y.»);
}
data = ””;
}
}

Версии Arduino Bluetooth Automation