Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SoftwareSerial.h>
- SoftwareSerial BT(2, 3);
- // creates a "virtual" serial port/UART
- // connect BT module TX to D10
- // connect BT module RX to D11
- // connect BT Vcc to 5V, GND to GND
- void setup()
- {
- Serial.begin(9600);
- // set digital pin to control as an output
- pinMode(13, OUTPUT);
- pinMode(7,INPUT);
- // set the data rate for the SoftwareSerial port
- BT.begin(9600);
- // Send test message to other device
- BT.println("Hello from HC06");
- }
- char a; // stores incoming character from other device
- float n;
- void loop()
- {
- if (BT.available())
- // if text arrived in from BT serial...
- {
- n = analogRead(A5)*5.0/1023.0;
- a=(BT.read());
- if (a=='1')
- {
- digitalWrite(13, HIGH);
- BT.println("LED on");
- }
- if (a=='2')
- {
- digitalWrite(13, LOW);
- BT.println("LED off");
- }
- if (a =='3')
- {
- BT.println("Napięci wynosi: ");
- BT.println(n);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement