تفضل اخي
Bluetooth Module Details:
JY-MCU Arduino Bluetooth Wireless Serial Port Module
Default password: 1234
Baud rate: 38400
Dimensions: 1.73 in x 0.63 in x 0.28 in (4.4 cm x 1.6 cm x 0.7 cm)
PINOUT
PIN DESCRIPTION
1 KEY
2 VCC
3 GND
4 TXD
5 RXD
Adruino Code:
كود:
int state = 0;
int incomingByte;
void setup() {
//set pin 12 to output mode
pinMode(12, OUTPUT);
Serial.begin(9600);
}
void loop() {
// see if there's incoming serial data:
if (Serial.available() > 0) {
// read the oldest byte in the serial buffer:
incomingByte = Serial.read();
// depending on the incoming byte do the needful action
if (incomingByte == '1') {
digitalWrite(12, HIGH);
delay(500);
Serial.println("ON");
state=1;
}
else if (incomingByte =='2') {
digitalWrite(12, LOW);
delay(500);
Serial.println("OFF");
state = 0;
}
}
if(state)
Serial.println("ON");
else
Serial.println("OFF");
delay(250);
}