Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SoftwareSerial.h>
- SoftwareSerial bluetooth(10, 11); // RX, TX
- int ledPin = 3;
- char command;
- void setup() {
- pinMode(ledPin, OUTPUT);
- bluetooth.begin(9600); // Start Bluetooth communication
- Serial.begin(9600);
- }
- void loop() {
- if (bluetooth.available() > 0) {
- command = bluetooth.read(); // Read command from Bluetooth
- Serial.println(command);
- if (command == '1') {
- digitalWrite(ledPin, HIGH); // Turn on LED
- } else if (command == '0') {
- digitalWrite(ledPin, LOW); // Turn off LED
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement