/* * FioV3_2Serial_9600.ino * (c)2013 Forward Computing and Control Pty. Ltd. * www.forward.com.au * This code may be freely used * * Use this sketch AFTER the baud rate of the RN42-HID has been changed to 9600 * (The factory default is 115200. Use FioV3_2Serial_115200.ino to change it to 9600.) * see http://www.forward.com.au/pfod/ArduinoProgramming/FioV3/index.html for details * * RN-42 Xbee bluetooth board has default hardware control * so connect pins 12 to 16 on the RN-42 (XBee) bluetooth module as FioV3 does not connect these pins * default baud rate is 115200 * * NOTE $$$ does NOT have so set monitor for "No Line endings" when issuing this string * once in cmd mode then set monitor back to "CR LF endings" * --- exits cmd mode * * RN42-HID * After Factory defaults * Baud rate 115,200 * 8 bits * No Parity * 1 stop bit * Hardware flow control enabled SO need to short pin 12 to 16 for this to work with FioV3 // use FioV3_2Serial_115200.ino to Change baud rate to 9600 SU,9600 then reboot R,1 // then use FioV3_2Serial_9600.ino to configure the module SM,0 Slave mode, in this mode other Bluetooth devices can discover and connect to the device. SA,4 Authenication, This mode is PIN code mode, which forces Bluetooth version 2.0 PIN code authentication. (see RN-HID-User Guide-1.1r.pfd) SP,0000 Set the pin code to 0000 (choose some over value here for security) ST,0 Configuration timer, ST,0 disables remote configuration and prevents anyone changing the config via the bluetooth connection. S~,0 D- ***Settings*** BTA=0006664CCD98 BTName=FireFly-CD98 Baudrt=9600 Mode =Slav Authen=0 PinCod=000 Bonded=0 Rem=NONE SET R,1 Reboot! $$$CMD CMD */ void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); // this should match the USB driver connect baud rate of 9600 Serial1.begin(9600); // change this to 9600 after changing the bluetooth baud rate } void loop() { if (Serial1.available()) Serial.write(Serial1.read()); if (Serial.available()) { byte in = Serial.read(); Serial.write(in); // local echo Serial1.write(in); } }