Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #include <SoftwareSerial.h>
  2.  
  3. SoftwareSerial BT(10, 11); //10-tx, 11-rx
  4. char BluetoothData;
  5. //float pi = 3.14;
  6. //boolean ok = false;
  7. //char BluetoothData2[10];
  8.  
  9. void setup() {
  10. // put your setup code here, to run once:
  11. //dtostrf(125.65,10,3,BluetoothData2); //conversie float to char
  12. pinMode(LED_BUILTIN, OUTPUT);
  13. Serial.begin(9600);
  14. BT.begin(9600);
  15. }
  16.  
  17. void loop() {
  18. // put your main code here, to run repeatedly:
  19. if (BT.available()) { //verific cat timp este conectat la modulul bluetooth
  20. BluetoothData = BT.read(); //salvez in variabila BluetoothData cea ce primesc prin transferul serial
  21. if (BluetoothData == '1') {
  22. digitalWrite(LED_BUILTIN, HIGH); // in functie de mesajul primit se va aprinde respectiv stinge un led de pe arduino
  23. BT.println("LED on"); //mesajul de aici va fi afisat pe android, in aplicatia creata de rares
  24. } else if (BluetoothData == '0') {
  25. digitalWrite(LED_BUILTIN, LOW);
  26. BT.println("LED off");
  27. }
  28. }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement