Close

Programming The User Interface

A project log for Arduino Bicycle Light

Arduino Nano controller 10W LED bicycle light with addressable LED strip, EL wire, temp sensor for LED, voltage sensing for 3.7v LiPo.

scottacranescottacrane 09/13/2016 at 20:160 Comments

Let's talk about programming the user interface and how I want my light to work when I only have essentially a power switch and a on/off touch sensor available. How do you control multiple items using just one "button"? Read on and I'll tell you.

On startup, the first thing I thought was like a car when you first start it and all the lights go on. I'm thinking the same thing. Of course after setting up the pins for the I/O I want. Turn on 10W lamp, EL wire, and all three RGB LED colors for all addressable lights for 2 seconds and then alternate 3 primary colors on RGB LEDs, 1 second each.

Then on to setup mode. But first, read battery voltage and somehow map to color bar perhaps weighed more to the front of the bike where I can see the addressable LEDs better. Maybe just the first 10 LEDs. The display would also be more useful skewed to show a 3v to 4v range because you don't want to deplete the LiPo any lower (and I also plan on monitoring and gracefully shutting down when the voltage gets too low).

While the battery level is shown on the addressable LEDs, the EL wire would "blink" off and back on to indicate that we are setting it up. My thought was to go into a loop for 5 seconds. If no capacitive touch, blink once more and go on. If the metal housing is touched, the EL wire state would toggle on to off or vice versa and restart the 5 second timer. So leave it alone if you like its current state, otherwise touch the lamp to change it. The initial and final blink indicate the entering and exiting of the EL wire setup. Always think about having your device give you feedback when trying to control it.

On to the main lamp. Again, quick flash to indicate enter and exit and with a 5 second timeout. For the lamp though I'm thinking as long as you are touching the lamp, the brightness would slowly ramp up and down including a brief pause while off. Remove your finger and the lamp would stay at that brightness. Wait 5 seconds and the setting sticks.

Finally, the addressable LEDs. I've done a pair of the neopixel glasses that I programming with multiple modes with just one button using long and short "clicks". I thought about using similar techniques here to alternate and pick the display mode and or color. But I've found just having a random changer between modes/colors works best.

After the setup I'm thinking that the only control you would want or need would be LED brightness in a similar way as the setup. Otherwise, you could just toggle the power if you wanted to turn the EL wire off, but leave the headlight on for example.

Discussions