JY-MCU Arduino Bluetooth Wireless Serial Port Module
Jump to navigation
Jump to search
JY-MCU Arduino Bluetooth Wireless Serial Port Module
VCC 3.6V - 6V
Premiers pas
Branchement
BT -----> Arduino ----------------- VCC ----> +5V GND ----> GND TX -----> D0 RX RX -----> D1 TX
- chargez le programme BluetoothEcho.ino sur l'Arduino en débranchant le VCC du module BT
- débranchez l'Arduino
- rebranchez le VCC du module BT sur le 5V de l'Arduino : la led rouge du module clignote
- rebranchez l'Arduino sur son l'alimentation (ou l'USB)
- appariez le device BT (le nom par défaut est "linvor") sur votre téléphone Android : la clé par défaut est "1234" : la led rouge du module est fixe (on)
- utilisez l'application BlueTerm disponible sur l'Android Market Google Play
- changez la diode embarquée (13) au moyen des touches 'l' et 'h'
// BluetoothEcho.ino char val; // variable to receive data from the serial port int ledpin = 13; // LED connected to pin 13 (on-board LED) void setup() { pinMode(ledpin, OUTPUT); // pin 13 (on-board LED) as OUTPUT Serial.begin(9600); // start serial communication at 9600bps // the default baud rate for http://dx.com/p/jy-mcu-arduino-bluetooth-wireless-serial-port-module-104299 } void loop() { if( Serial.available()) // if data is available to read { val = Serial.read(); // read it and store it in 'val' } if( val == 'h' ) // if 'l' was received { digitalWrite(ledpin, HIGH); // turn ON the LED Serial.write('H'); } else if( val == 'l' ) // if 'l' was received { digitalWrite(ledpin, LOW); // turn it OFF Serial.write('L'); } else if(val>=32 && val <127) { // otherwise echo the read char Serial.write(val); } val=0; delay(100); // wait 100ms for next reading }
Utilisation avancé
- To initlalize the BT module, send it the following AT commands: AT+PIN1234 <cr> AT+NAMEdongle <cr> AT+BAUD4 <cr>. The last command will set the baud rate to 9600.
- Then on the PC, connect to a new Bluetooth device, use the same PIN number as above, make note of which serial (COM) port it maps to and then use Putty (Windows) or screen (Linux) to test!
Read the forums http://club.dx.com/forums/Forums.dx/threadid.1166641
// @from http://club.dx.com/forums/Forums.dx/threadid.1166641 // @see http://arduino.cc/en/Reference/SoftwareSerial #include <SoftwareSerial.h> SoftwareSerial mySerial(10, 11); // RX, TX void setup() { Serial.begin(9600); Serial.println("Goodnight moon!"); //mySerial.begin(115200); mySerial.begin(9600); delay(1000); mySerial.print("AT"); delay(1000); mySerial.print("AT+VERSION"); delay(1000); mySerial.print("AT+PIN1342"); // Set pin to 1342 delay(1000); mySerial.print("AT+NAMEFresaBT"); // Set the name to FresaBT delay(1000); //mySerial.print("AT+BAUD8"); // Set baudrate to 115200 mySerial.print("AT+BAUD4"); // Set baudrate to 9600 delay(1000); } void loop() // run over and over { if (mySerial.available()) Serial.write(mySerial.read()); if (Serial.available()) mySerial.write(Serial.read()); }