Control LEDs on the Arduino from your Android Phone.
This is the example code from my PhoneGap for Makers talk at the 2013 Maker Faire Bay Area.
Hardware
- Arduino Uno
- SparkFun Bluetooth Mate Silver
- Adafruit NeoPixel Digital RGB LED Weatherproof Strip 60 LED
TODO Fritzing diagram here
Upload the sketch to your Uno using the Arduino IDE.
Pair your Android phone with the bluetooth adapter.
This assumes you have the Android SDK installed and $ANDROID_HOME/tools and $ANDROID_HOME/platform-tools in your system path.
Adding platforms generates the native project
$ cordova platform add android
Install the Bluetooth Serial plugin with cordova
$ cordova plugin add cordova-plugin-bluetooth-serial
Connect your phone to the computer.
Compile and run the application
$ cordova run
After the application starts, connect bluetooth by touching the "Connect" label. Occasionally it takes a few times to connect. Watch for the green connect light on the Bluetooth adapter.
Move the sliders to adjust Red, Green, and Blue values.
This code also works with iOS as long as you use a RedBearLabs BLE radio or the Adafruit Bluefruit LE
For the RedBear radios upload the PhoneGapLED.ino sketch to your Uno using the Arduino IDE.
For the Adafruit Bluetfruit LE radio upload the PhoneGapLED_BluefruitLE.ino sketch to your Uno using the Arduino IDE.
Adding platforms generates the native project
$ cordova platform add ios
Install the Bluetooth Serial plugin with cordova
$ cordova plugin add cordova-plugin-bluetooth-serial
$ cordova prepare
$ open platforms/ios/LED.xcodeproj
Build the code and deploy to your iPhone using Xcode