Today's 'Fun with Flowcode' project.
I wanted to tie together several ideas based on recent (and historic) forum topics. (Bluetooth, parsing commands in a datastream, converting Ascii to int and i2c)
So here we have a Bluetooth controlled mood light.
I used a BlinkM MaxM Blaster LED - which is bright (very bright) - but this would be easy to convert to another LED light (even PWM RGB for a low budget (& low light) option) (see https://thingm.com/fileadmin/thingm/dow ... asheet.pdf)
The circuit is simple - the LED controller is connected via i2c to a4/a5 on the Arduino (with 4.7k pullups) The LEDs need a separate power supply (in this case I'm using a 12v adapter)
Bluetooth (HC-05) is connected to Tx and Rx pins on the Arduino via a level shifter for the data pins (to bring things down to 3.3v) The level shifter needs 5v, and 3.3v sources and 2x GND.
I wanted a slightly more general command structure - so I'm using a 3 character command string for matching to received data (I convert the received data to upper case to allow more easier operation) - currently there are 4 commands (RED set red, BLU set blue and GRN set green (0..255 value) and PRG - set demo mode to 'n'. Note that I convert the commands to a long integer value (there isn't an easy way to initialise an array of strings in FC) It would be easy to allow 4 character commands.
So for example red255 would set RED LED to max brightness
PRG018 would set demo 18 running.
Commands can be chained (eg RED255BLU100GRN100) - though it works it doesn't make much sense to chain PRG commands.
Commands are echoed to Bluetooth - the data could also be sent via USB (using a terminal prog) - commands are not echoed (but it works ok)
The command set current is ABCnnn where ABC is the command string and nnn is a 3 (or less) digit decimal value. it would be good to have a RGBrrrgggbbb command - but I've left this out for simplicity..
Martin(1) - a graphical front end for the controller would be great (sliders for RG and B!) or a SCADA front end!
I used Serial Bluetooth (free on Play Store) on my (Android) phone.
Enjoy
Martin
Mood light
Tips, Tricks and methods for programming, learn ways of making your programming life easier, and share your knowledge with others.
Return to “Programming Tips & Tricks”
Jump to
- Announcements
- ↳ Announcements
- The Knowledge Exchange
- ↳ Programming Tips & Tricks
- ↳ Freelance Embedded Engineers
- ↳ Article Discussion
- Microcontroller Programming
- ↳ General Programming
- ↳ Flowcode V9
- ↳ Flowcode V8
- ↳ Feature Requests
- ↳ Bug Reports
- ↳ User Components
- ↳ Flowcode V7
- ↳ User Components
- ↳ Feature requests
- ↳ Bug reports
- ↳ Fixed bugs
- ↳ 8-Bit PIC
- ↳ 16-Bit PIC
- ↳ 32-Bit PIC
- ↳ AVR & Arduino
- ↳ 32-Bit ARM
- ↳ Poll Discussion
- ↳ Flowcode V6
- ↳ Flowcode v6 Beta
- ↳ Bug reports
- ↳ Getting Started
- ↳ User Components
- ↳ Feature requests
- ↳ Bug reports
- ↳ Flowcode V5
- ↳ Flowcode V5 Issues
- ↳ Flowcode V5 Suggestions
- ↳ Flowcode V5 Free Edition
- ↳ Flowcode V4
- ↳ Flowcode 4 Bugs
- ↳ Flowcode 4 Suggestions
- ↳ Flowcode V2 & V3
- ↳ General / Misc
- ↳ Components (Comms)
- ↳ Components (Other)
- ↳ Bugs / Application Errors
- ↳ Suggestions
- ↳ BTEC Unit 6
- ↳ C and ASM Programming
- ↳ E-blocks
- ↳ Formula AllCode
- ↳ Formula Flowcode
- ↳ MIAC
- Language Support Forums
- ↳ Deutsch Support-Forum
- ↳ Forums d'aide en français
- ↳ Foro de soporte español
- Other Matrix products
- ↳ Electronics products
- ↳ Matrix Online Courses
- ↳ Other products
- ↳ CoCo
- Hidden