Randomly blinking lights

As always, the video of my project working can be found here. My project works as follows. A user is asked to put a pulse sensor on her finger. In her other hand, she presses a button, which turns on a minimum of one light, and a maximum of four lights. Above the lights on the panel are four switches. The user is not prompted to interact with these switches, but I’ve found, at least anecdotally, that he or she almost always will. These switches load on to a master probability distribution which determines how many lights will turn on. Each switch is associated with a function that takes some parameter and the user’s current pulse rate as arguments. The master probability function is the logistic function. The switches influence the logistic functions ‘k’ parameter, changing the shape of the function. Note that as pulse increases, the chance of turning on all four lights gets increasingly close to zero. Each of the lights is turned on once a preset threshold is met. For example, if the logistic function, evaluated at some randomly chosen point was above 0.47, then the first light would turn on. The thresholds are on a bit of a log scale, such that the 1st threshold is around 0.5, the second is around 0.75, the third is around 0.9, and the fourth is around 0.99.

Upon using my project, it seems clear that at least some of the switches influence how the lights turn on, but its unclear how the switches are related. Instead of directly adding terms to the master probability distribution, the switches influence the parameter that controls the shape of the master probability distribution. This means that the effect of the switches isn’t felt as strongly as directly adding terms. Luckily for me, the logistic function and the functions associated with each switch are relatively stable. This means that a small change in input results in a correspondingly small change in output.

Troubleshooting Arduino code is a little annoying for me because it’s more difficult to see what’s going on incrementally compared to Python. As such, I prototyped my master probability function, along with all the functions that load onto it with an iPython notebook (I guess it’s called Jupyter now). I found that the best way to select appropriate parameters for the loading functions was by using iPython’s interactive plotting ability. Once I had a good idea what these were, I hard coded them in my Arduino code.

Leave a Reply