In addition to the UART functionality in BlueFruit
, you can also use Firmata to control the pins on your Uno. Firmata
is a light weight protocol that was designed to make it possible to control an Uno from a variety of external devices, such as you laptop using another programming language. We've ported Firmata over to BLE using our Adafruit_BLE_UART as the transport layer, and created an easy to use IDE to help you get started with it.
At this time, our Firmata sketch/App support is limited to iOS devices. BLE is relatively new to the Android ecosystem and there are only a handful of devices that support it today, and the stack itself is still in active development and has some issues that will no doubt be resolved in future updates. For the moment, though, we have made the decision to concentrate our limited resources on iOS since this is the still statistically the most natural target plaform in the BLE world.
The first thing you'll need to do is download the Adafruit_BLE_PinIO repository from Github, and install it in your Arduino libraries folder (ex.: libraries/Adafruit_BLE_Pin_IO) just like you did with Adafruit_nRF8001. Download and unzip the library, rename the folderAdafruit_BLE_Pin_IO making sure that it contains Adafruit_BLEFirmata.cpp and .h Then install that into your libraries folder
The Adafruit_PinIO sketches also requires Adafruit_nRF8001 to be present in your libraries folder but you already installed that so you should be good to go if you went through the UART echo tests.
Once this library is installed, open up the StandardFirmata sketch (File > Examples > Adafruit_BLEFirmata > StandardFirmata), compile the sketch, and program the Uno with your firmware.
Next, open Adafruit Bluefruit LE Connect on your iOS device and select the Pin I/O option on the home page:
This will establish a connection between the nRF8001 and your iOS device, and you should see an I/O screen that allows you to select any available pin.
Wiring up for Firmata demo
The Firmata BLE app demo allows you to some basic functionality with your Arduino, great for testing out ideas or sensors
- Digital Input (e.g. switches)
- Digital Output (e.g. relays)
- Analog Input (e.g. sensors)
- PWM Output (e.g. LED dimming)
We'll demo all of these with the following wiring, grab some components from your parts bin and follow along!
- Connect a standard LED (any color) with a inline resistor (220-1K is fine) to Digital 7
- Connect an RGB LED (either common cathode or anode) so that the red, green and blue LED pins tie to Digital 3 5 and 6 with inline resistors. If using common anode, connect the fourth pin to 5V. If using common cathode, connect it to GND.
- Connect a switch of some sort to Digital 4 so that when pressed, it connects to ground. No pullup resistor is required
- Connect a potentiometer (any value 500 ohm to 1Mohm) so that the two outer legs connect to 5V and GND and the middle pin connects to Analog 5
Simply click on the pin that you wish to manipulate (pin 3 is selected
in the screenshot below), set one of the three pin modes (Input, Output, PWM or Analog mode), and adjust the settings accordingly:
Some of the various options can be seen below, such as the ability to change the PWM rate when you select PWM mode, or whether to set output pins high or low, etc.:
This mode will setup the pin as an input, and the latest pin state will be displayed as High
In Output Mode you can set the pin state yourself to High
, allowing you to manually toggle an LED, enable or disable a FET driving a heavy load, etc.:
This guide was first published on Mar 20, 2014. It was last
updated on Mar 20, 2014.
This page (Software: BlueFruit Pin I/O) was last updated on Aug 23, 2015.
PWM Mode allows you to set adjust the PWM output on a pin between 0 and 255 using a convenient slider, as shown below: