I am working on a project to get the bluetooth to accomplish tasks when it determines there is a trusted device within range (hopefully using the rssi feature of the radio). We tried to load this simple program on the board to get the microcontroller to read info from the radio.
/*
* Blink
*
* The basic Arduino example. Turns on an LED on for one second,
* then off for one second, and so on... We use pin 13 because,
* depending on your Arduino board, it has either a built-in LED
* or a built-in resistor so that you need only an LED.
*
* http://www.arduino.cc/en/Tutorial/Blink
*/
int ledPin = 13; // LED connected to digital pin 13nt
int digiIn = 12;
int RESET = 7;
int incomingByte = 0; // for incoming serial data
void setup() // run once, when the sketch starts
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
pinMode(digiIn, INPUT); // sets the digital pin as input
Serial.begin(115200); // connect to the serial port
digitalWrite(RESET, HIGH);
delay(10);
digitalWrite(RESET, LOW);
delay(2000);
// the following "SET BT" commands are one-time commands
// that only need to be uploaded to your BT module and run
// when you want to change the BlueGiga's configuration.
// ok. First, the easy to change configuration commands:
Serial.println("SET BT NAME Arduino_BT"); // you can change the name of your module here.
// No spaces allowed in the name; names can be up to 256 charcters.
// Serial.println("SET BT NAME KarlMarx"); // example
Serial.println("SET BT AUTH * 12345"); // 12345 == 0 to 16 digit Bluetooth passkey/PIN code
// Serial.println("SET BT AUTH * 987654321"); // example
// And now the tricky configuration commands.
// Change these only if you know what you're doing.
// See the IWRAP manual for details.
Serial.println("SET CONTROL BAUD 115200,8n1"); // set the BT module serial rate to 115200. Don't change this.
Serial.println("SET BT PAGEMODE 3 2000 1"); // 3 == IWRAP visible and answers
// 2000 == 5120ms timeout
// 1 == iWRAP is connectable every 1.28 sec
Serial.println("SET BT ROLE 0 f 7d00"); // 0 == allows master-slave switch when calling;
// f == enable sniff, park, hold and role switch modes;
// 7d00 == keep connection alive 20 seconds
Serial.println("SET CONTROL CD 80 0"); // Carrier Detect IO7 goes high
Serial.println("SET CONTROL ECHO 0"); // don't echo back module commands
Serial.println("SET CONTROL ESCAPE - 00 1"); // - == character to escape from comand mode to data mode;
// 00 == DTR bitmask; 1 == return to command mode when DTR dropped
}
void loop() // run over and over again
{
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
}
}
when we tried to use the serial monitor we get this error
java.lang.NullPointerException
at processing.app.Serial.write(Serial.java:453)
at processing.app.Serial.write(Serial.java:476)
at processing.app.EditorStatus.actionPerformed(EditorStatus.java:521)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)