Conecto o HC-06 RXD no pino 6 do arduino mega, e TXD no pino 7 do mega

#include <SoftwareSerial.h>
int bluetoothTx = 7;
int bluetoothRx = 6;
int led = 13;

SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);

void setup() {
bluetooth.begin(9600);
pinMode(led, OUTPUT);
Serial.begin(9600);
digitalWrite(led,0);

}
void loop() {

if(bluetooth.available()>0)
{
unsigned int blue = bluetooth.read();

if(blue == 100){

Serial.println("Liga");
delay(100);
}
if(blue == 200){

Serial.println("Desliga");
delay(250);
}

}
}

Exibições: 134

Responder esta

© 2024   Criado por Marcelo Rodrigues.   Ativado por

Badges  |  Relatar um incidente  |  Termos de serviço