This instructable will cover how to connect adafruit's BlueFruit to the arduino and then establish a line of communication with OpenFrameworks. For the purpose of this guide we are just using a photoresistor to show how you can recieve information from the arduino into OF, but you could use any sensor you wish!
9v battery and adaptor for Arduino
Code / Libraries
Arduino Tester Code to check connection!
Our OpenFrameworks code!
Step 1: Hook Up Arduino to BlueFruit
Refer to Schematic for how to connect everything to the arduino!
GND -- Arduino GND
VIN -- Arduino 5v
TX -- Arduino RX
RX -- Arduino TX
DTR -- Capicitor +-- Arduino Reset
Either with an adaptor to the Arduino's power input
Positive -- Arduino Vin
Negative -- Arduino GND
First leg -- Power
Second leg -- Resistor -- GND
Second leg -- A0
Step 2: Connect Bluefruit to Computer
Once you have your Ardunio all hooked up you need to establish a bluetooth connection with your computer. We aren't too sure about doing this on a PC but if you go on adafruit's website they provide information on setting it up!
If you're on a Mac you're in luck because so are we!
- Click on you're bluetooth icon at the top of your screen & make sure your bluetooth is on!
- From the drop down menu select Setup Bluetooth Device
- A list of near by devices will come up select your Bluefruit it should be named something like "Adafruit Ez-link"
- After a connection is made you will get a congratulations message! yay!
- Next you will need to select Browse Device from the drop down list
- A dialogue box will appear select the "Adafruit Ez-link ..." once again this will connect your computer to the device.
Step 3: Recieving Values in Arduino
Now that your computer and ardunio have a connected bluetooth communication you will want to send information back and forth!
First you will want to load a quick sketch onto your arduino to test that your sensor is working and then that the bluetooth is sending to your serial port wirelessly.
We wrote up some quick test code using the photoresistor that can be found here.
- Download and open our code in Arduino
- Connect your Arduino set up to the computer with your USB
- Run the code so it is loaded onto the board, I would also suggest that at this point checking that everything regarding your code / sensor is working. This code takes in the value from A0 (our photoresistor) and prints it to the Arduino serial console. Check that you are receiving values and that it is behaving appropriately.
- Now for the unplugging of the Arduino!!! Disconnect your USB :O
- You will now want to change the input on your computers Arduino Console so you can receive the values wirelessly in the Arduino serial console. Go to Tools > Serial Port > /dev/cu/nameofbluetoothdevice
- Now click on your serial console to see the magic happen! You will also notice when the bluefruit is sending information the lights will be going crazy which can be a helpful way to debug any issues.
Step 4: Send Stuff to Open FrameWorks!
Now that you know that everything is happy and talking to each other you can send your data to OF to do awesome crazy beautiful things.
We are connecting and sending this data by sending Bytes from Arduino's serial port to OpenFrameworks.
***Special thanks Gabor Tankovics for the OF code!!!***
Download ourArduino Code hereand our OpenframWorks code can be downloaded on this page!
Everything is commented to explain what each part of the code does.
The code we have provided is the bare minium of what you need to show how to send data between the two programs. The OF sketch just shows how to recieve the data and print it to the console, but so much is possible!
Please refer to the above diagram of the code where we have highlighted the important connections between the two sketches!
*****Remember to load the Arduino code onto the Arduino board by using the USB first then disconnecting it*********
CREATE AWESOME CRAZY THINGS WITH YOUR NEW WIRELESS CONTROLLER