Hallo
Ik krijg het niet voor elkaar.
ik wil in deze sketch ,dat als ik b(van blink) in druk hij gaat blinken het ledje op pin 12.
Arduino Uno ,met bluetooth HC-06.
opzich werkt het ,enkel dat blinken krijg ik niet voor elkaar.
En als hij dan blinkt dat als ik dan weer l(van LOW) in druk dat het stopt.
en dat dan sketch verder door loopt.
c code:
#include <SoftwareSerial.h>
SoftwareSerial BT(10, 11);
// 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()
{
// set digital pin to control as an output
pinMode(12, OUTPUT);
// set the data rate for the SoftwareSerial port
BT.begin(9600);
// Send test message to other device
BT.println("Hello from Arduino");
}
char a; // stores incoming character from other device
void loop()
{
if (BT.available())
// if text arrived in from BT serial...
{
a=(BT.read());
if (a=='h')
{
digitalWrite(12, HIGH);
BT.println("LED on");
}
if (a=='l')
{
digitalWrite(12, LOW);
BT.println("LED off");
}
if (a=='b')
{
digitalWrite(12, HIGH); // Zet de LED aan door het voltage hoog te maken
delay(1000);
digitalWrite(12, LOW); // Zet de LED uit door het voltage laag te maken
delay(1000);
BT.println("LED ON OFF");
}
if (a=='?')
{
BT.println("Send 'h' to turn LED on");
BT.println("Send 'l' to turn LED off");
BT.println("Send 'b' to turn LED on off");
}
// you can add more "if" statements with other characters to add more commands
}
}
wie weet een oplossing???
[Bericht gewijzigd door Henry S. op zondag 29 mei 2016 16:53:30 (0%)