JY-MCU Arduino Bluetooth Wireless Serial Port Module: Difference between revisions

From air
Jump to navigation Jump to search
No edit summary
No edit summary
Line 4: Line 4:
VCC 3.6V - 6V
VCC 3.6V - 6V


==Premiers pas==
# 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
# rebranchez l'Arduino sur son l'alimentation (ou l'USB)
# appariez le device BT (linvor) sur votre téléphone Android : la clé est 1234
# utilisez l'application [http://pymasde.es/blueterm/ BlueTerm] disponible sur l'Android market Google Play
# changez la diode embarquée (13) au moyen des touches 'l' et 'h'


<pre>
// 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 'H' was received
{
digitalWrite(ledpin, HIGH); // turn ON the LED
Serial.write('H');
} else if( val == 'l' ) // if 'H' was received
{
digitalWrite(ledpin, LOW); // otherwise turn it OFF
Serial.write('L');
} else if(val>=32 && val <127) {
Serial.write(val);
}
val=0;
delay(100); // wait 100ms for next reading

}

</pre>


==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.
* 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.

Revision as of 21:32, 7 May 2013

JY-MCU Arduino Bluetooth Wireless Serial Port Module


VCC 3.6V - 6V

Premiers pas

  1. chargez le programme BluetoothEcho.ino sur l'Arduino en débranchant le VCC du module BT
  2. débranchez l'Arduino
  3. rebranchez le VCC du module BT sur le 5V de l'Arduino
  4. rebranchez l'Arduino sur son l'alimentation (ou l'USB)
  5. appariez le device BT (linvor) sur votre téléphone Android : la clé est 1234
  6. utilisez l'application BlueTerm disponible sur l'Android market Google Play
  7. 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 'H' was received
  {
    digitalWrite(ledpin, HIGH);  // turn ON the LED
    Serial.write('H');
  } else if( val == 'l' )               // if 'H' was received
  {
    digitalWrite(ledpin, LOW);   // otherwise turn it OFF
    Serial.write('L');
  } else if(val>=32 && val <127) {
    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());
} 

Tools