Writing firmware to operate a microcontroller such as the Arduino can provide the user with an array of power at his disposal, but the processing power and further interaction is limited due to the nature of the microcontroller itself (its a MICROcontroller aka not an Intel processor). With this in mind, I was interested in interacting with the Arduino on my PC. At first I thought I would have to do this in C using Visual Studio and the Windows library (to talk to the COMM PORTS); however, I found another open source compiler from the creators of the Arduino sketchbook called Processing:
"Processing is an open source programming language and environment for people who want to create images, animations, and interactions. Initially developed to serve as a software sketchbook and to teach fundamentals of computer programming within a visual context, Processing also has evolved into a tool for generating finished professional work. Today, there are tens of thousands of students, artists, designers, researchers, and hobbyists who use Processing for learning, prototyping, and production"
-www.processing.org
Here's the simple setup for downloading Processing and setting it up for Arduino interaction:
Create a folder in your Processing folder called "libraries"; the Processing folder is most likely loaded in your My Documents (not to be confused with the processing zip file that you just downloaded)
Copy the Arduino folder from the extracted file into the Processing folder
Open up the Processing sketchbook, click Sketch->Import Library and you should see an Arduino library at the bottom of the list
You are good to go! Just include the Arduino library and the Serial library anytime you use Processing to interact with the Arduino. Examples can be found on the Processing website and on the Arduino website (www.arduino.cc)
For my next project I am going to use an infrared sensor to detect motion and use the Arduino and Bluetooth to wirelessly report whenever the motion detector goes off using the Processing sketchbook.
Programming chord USB: to program Arduino- comes with Arduino
Power supply (used an old iPhone charger: 5V)- Best Buy
Windows XP (can use others but steps may vary)- Microsoft
Stage 1: Installing Bluetooth and discovering BlueSmirf
Plug in USB Dongle into computer- Bluetooth icon should appear in task bar
Click on Bluetooth icon, and adjust settings by clicking on Options>check "Turn Discovery On", "Allow Bluetooth devices to connect to this computer">Click Apply
Next, power up the BlueSmirf with Dongle connected to computer
Click on Bluetooth icon>Devices>Add..>Check "My device is set up and ready to be found"> Click "Next"
The Bluetooth should detect the device (name should come up as FireFly-<ID>), if it does not detect...Try different ways such as restarting the computer, adding the device again, and making sure the BlueSmirf has solid connections (I soldered it to headers)
If it installs properly, at the end of the Bluetooth wizard you should see something like this:
Make not of the Outgoing COM port, as that will be the port you use to communicate with the BlueSmirf and Arduino
The FireFly-BE11 (BE11 was what it was on mine) will show up under your Bluetooth devices
Then, you must connect the device to the computer. Open up HyperTerminal: Start>Programs>Accessories>Communications>HyperTerminal
A prompt will pop up saying the device wants to connect to the computer...click on prompt. It will ask for a password, type in 1234, and your device is paired! You do not have to do this again after the first time (unless you remove the FireFly device from the Bluetooth device list)
Stage 2: Building the circuit and programming the Arduino
I soldered headers onto the BlueSmirf for good connections
See following picture for connecting circuit (Use P0 and P1 for Rx and Tx instead, and I used P3 as the port to control the LED)
Now unplug the BlueSmirf, connect the USB serial programmer from the computer to the Arduino, I used the following code:
int counter;
byte newbyte;
void setup() {
Serial.begin(9600);
pinMode(3,OUTPUT);
digitalWrite(3,HIGH);
delayMicroseconds(1000);
counter=0;
newbyte='h';
}
void loop() {
// put your main code here, to run repeatedly:
if(Serial.available()>0){
newbyte=Serial.read();
if(newbyte=='h'){
digitalWrite(3,HIGH);
}
else
digitalWrite(3,LOW);
}
Serial.println(counter,DEC);
counter++;
delay(300);
}
Once the Arduino is programmed, unplug the USB connection and re-connect the BlueSmirf
Stage 3: Talking to the Arduino using the commandline
Power up the Arduino/BlueSmirf- red light should be blinking on the BlueSmirf
Open up HyperTerminal, follow the steps below:
Type in a name for the connection (I used "Bluetooth")
Under the 'Connect Using' menu, select the COM port that was the Outgoing COM port when installing the Bluetooth (can also check again by clicking on the Bluetooth icon>COM Ports Tab) and then click OK
Should see the counter in progress
Can enter command mode by pressing '$$$' followed by Enter
Exit command mode by pressing '---' followed by Enter
Can configure the BlueSmirf in command mode
Can turn the LED on and off by pressing any key to turn it off, and 'h' to turn it on
VIDEO DEMO OF STAGE 3:
NOTES FOR USING BLUESMIRF INTERFACE WITH ARDUINO: Troubleshooting:
1. -Power up BlueSmirf
-Make connection through your Terminal (I used SimpleTerm Gold trial version) and get the green led -Type "$$$" before 60 secs from the power up, and it should respond with "CMD" and the red LED will flash -Type "H" -> Set commands -Type "SU,57600" -> to change the baudrate and respond "AOK" -Type "D" -> Display settings to see the new baudrate. -Reboot the BlueSmirf to make the change happen.
2. Solder connections to Bluesmirf for good connections
3. Use Hyperterminal (TeraTerm did not work for me): -Power Arduino and Bluesmirf on -Connect to COM7 (the SPP COM port) - $$$ -> command mode - --- -> exit command mode -Should bring up the counter from the arduino board -Can type commands, will get sent to Arduino