The final code

Aka. Ole fixing our code

Anna Freja Korvin
Anna Freja — DIA
3 min readApr 27, 2017

--

Seeing how we could not get our code to work on the LED strip at all the day before, we saw it nescessary to talk to Ole. Unfortunately Ole has been very busy since all groups needed his help, so the only session we could get with him was thursday, where two of our group members could not attend because of their jobs.

So we went to the session with Ole and brought our Arduino, LED strip and soft button along for him to examine.

During Ole’s first glance at our code he immediately noted that the code that we used to get our 2 states to work on an LED pin is not at all the code to use when trying to make an LED strip do the same thing. Me and Mette tried our best to follow all of Ole’s advice and I’ll try and do my best to explain what we had done wrong and how the code ended up looking below:

Setup

Showing the difference in the setup

Above can be seen the very major difference between our old code (1) and the new code Ole helped us with (2). In our old code our setup consisted the push button as the input and of the LED pin as the output and nothing more. Ole showed us that when working with an LED strip you need to add the “Adafruit_NeoPixed” snippet before the setup — which defines the kind of LED-strip and how many LED’s are in the strip (120). And also below, in the setup, you have to add “strip-begin();” to enable it to turn on.

Random flicker

These code snippets show the difference between our old “random flicker” light sequence and Ole’s proposed new one. I must admit, that I understood the first one much better, as Ole is very mathematically thinking and I on the other hand am not. But what it is interesting to note, is the difference in skipping and grouping LED’s that we had not otherwise been able to do.
As can be seen there are two lines called “int skipLeds” and “int groupLeds” that are both random but within the intervals of respectively 0 to 30 and 0 to 6. Which means with each lighting sequence the LED strip will randomly skip between 0–30 of the separate LED’s within the strip, and it will also group between 0–6 to the same sequence. This added a more abrupt and visible lightning behaviour than we had before — which is necessary as our LED strips are placed inside of a pillow and beneath the teddy bear fabric (mentioned in the post “Settling on the Physical Form”).

--

--