Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SoftwareSerial.h>
- SoftwareSerial bluetooth(10, 11); // RX, TX
- int a1 = 6;
- int a2 = 5;
- String receivedBluetoothString = "";
- void setup() {
- bluetooth.begin(9600);
- pinMode(a1, OUTPUT);
- pinMode(a2, OUTPUT);
- }
- void loop() {
- while (bluetooth.available() > 0) {
- char receivedBluetoothChar = bluetooth.read();
- receivedBluetoothString += receivedBluetoothChar;
- if (receivedBluetoothChar == '\n') {
- if (receivedBluetoothString.toInt() == 887425) {
- digitalWrite(a1, HIGH);
- delay(500);
- digitalWrite(a1, LOW);
- } else if (receivedBluetoothString.toInt() == 887426) {
- digitalWrite(a1, HIGH);
- delay(1000);
- digitalWrite(a1, LOW);
- }
- receivedBluetoothString = "";
- }
- }
- }
Add Comment
Please, Sign In to add comment