Paste 2Vfb2

Submitted on 26 May 2016 at 11:44 UTC
4634 views

Section 1 (text)

#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 = "";
    }
  }
}

Raw · Download

Pastee