vanschagen
Heeft veel posts
- Lid geworden
- 16 jul 2013
- Berichten
- 10.367
- Waarderingsscore
- 2
hallo
Arduino in een sketch probeer ik een loopje als ik b in druk
dit is de code
ledje gaat branden en gaat weer uit ,ik wil dat het blijft knipperen .
en als ik dan weer l indruk dat hij uit gaat
Arduino in een sketch probeer ik een loopje als ik b in druk
dit is de code
HTML:
#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);
}
if (a=='?')
{
BT.println("Send 'h' to turn LED on");
BT.println("Send 'l' to turn LED off");
}
// you can add more "if" statements with other characters to add more commands
}
}
ledje gaat branden en gaat weer uit ,ik wil dat het blijft knipperen .
en als ik dan weer l indruk dat hij uit gaat
Laatst bewerkt door een moderator: