Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SoftwareSerial.h>
- SoftwareSerial BT(10, 11); //10-tx, 11-rx
- char BluetoothData;
- //float pi = 3.14;
- //boolean ok = false;
- //char BluetoothData2[10];
- void setup() {
- // put your setup code here, to run once:
- //dtostrf(125.65,10,3,BluetoothData2); //conversie float to char
- pinMode(LED_BUILTIN, OUTPUT);
- Serial.begin(9600);
- BT.begin(9600);
- }
- void loop() {
- // put your main code here, to run repeatedly:
- if (BT.available()) { //verific cat timp este conectat la modulul bluetooth
- BluetoothData = BT.read(); //salvez in variabila BluetoothData cea ce primesc prin transferul serial
- if (BluetoothData == '1') {
- digitalWrite(LED_BUILTIN, HIGH); // in functie de mesajul primit se va aprinde respectiv stinge un led de pe arduino
- BT.println("LED on"); //mesajul de aici va fi afisat pe android, in aplicatia creata de rares
- } else if (BluetoothData == '0') {
- digitalWrite(LED_BUILTIN, LOW);
- BT.println("LED off");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement