Advertisement
Guest User

Untitled

a guest
May 27th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #include <SoftwareSerial.h>
  2. SoftwareSerial BT(2, 3);
  3. // creates a "virtual" serial port/UART
  4. // connect BT module TX to D10
  5. // connect BT module RX to D11
  6. // connect BT Vcc to 5V, GND to GND
  7. void setup()
  8. {
  9. Serial.begin(9600);
  10. // set digital pin to control as an output
  11. pinMode(13, OUTPUT);
  12. pinMode(7,INPUT);
  13. // set the data rate for the SoftwareSerial port
  14. BT.begin(9600);
  15. // Send test message to other device
  16. BT.println("Hello from HC06");
  17. }
  18. char a; // stores incoming character from other device
  19. float n;
  20. void loop()
  21. {
  22.  
  23. if (BT.available())
  24. // if text arrived in from BT serial...
  25. {
  26.  
  27. n = analogRead(A5)*5.0/1023.0;
  28. a=(BT.read());
  29. if (a=='1')
  30. {
  31. digitalWrite(13, HIGH);
  32. BT.println("LED on");
  33. }
  34. if (a=='2')
  35. {
  36. digitalWrite(13, LOW);
  37. BT.println("LED off");
  38. }
  39. if (a =='3')
  40. {
  41. BT.println("Napięci wynosi: ");
  42. BT.println(n);
  43. }
  44.  
  45.  
  46.  
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement