This project was part of a Halloween themed challenge to make something cool
May 25, 2020
The HERP DERP event is hosted annually at Enova during Halloween. Here are some more details about the event as well as some other interesting past projects.
This project had a Vue.js frontend, Rails backend, Python script, and used some AWS sentiment features.
Our team created a program that allowed users to ask questions of our Principal Engineers. The program would then send the question through a stream of LED lights to the head of the Engineer, and a random answer would come back. The questions were also analyzed using Amazon sentiment, and the LED lights were colored according to the sentiment of the question.
For this project, my contributions included the physical connection of our LED lights to the Pi. I had to reflect back on some of my schematic/electrician skills I learned in the Air Force for this one. After getting the lights wired up correctly, I then had to learn how to control them with code. Since this event was in a hackathon format, I also had little time to get this figured out. Some quick googling taught me about a ready-made package in Python that could help me do this. I have some Python experience so this was great news. The issue however, was that the BE of this project was in Rails….
To move forward, we decided to just create a Python script that would be run from the rails code. I should also mention here that the majority of the lighting code was first pulled from a tutorial. I was then able to use that foundation and tweak it a bit to meet our teams specific needs.
One of the ideas of the team was that when a person asked a question of the principal engineers, that question should have a sentiment. This part was accomplished by some other team members using some AWS tools. My part came in when we decided that the sentiment of the question should determine the shade of light that was sent to the principle engineers. For positive sentiments the lights needed to be green, negative had to be red, and neutral white. Since amazon was already giving us the positive, negative, neutral determination all I had to do was act on that info in the Python script. I did that here:
for i in range(PIXEL_COUNT):
pixels.set_pixel_rgb(i, *color_from_sentiment(sentiment))
if sentiment == 'NEGATIVE':
if i == 0:
x = [64,64,255]
x[0] -= 2
x[1] -= 2
elif sentiment == 'POSITIVE':
if i == 0:
x = [64, 255, 64]
x[0] -= 2
x[2] -= 2
elif sentiment == 'NEUTRAL':
if i == 0:
x = [255, 96, 96]
x[1] -= 3
x[2] -= 3
else:
x = color_from_sentiment(sentiment)
pixels.set_pixel_rgb(i, *x)
The above is just the lights heading in one direction (meaning from the pi to the engineers). The lights traveling back is handled in another function. The way this works is by iterating over the pixels and setting different amounts of red, green, blue (depending on the sentiment) and then changing the shade as it travels.
I don’t know how great that explanation was, but IRL this was really cool to see. One other bit of fun I had with this project was to add an easter egg for a light show. If the question that was asked was easter egg, instead of the normal shading of lights, the user gets to see the full light show which was a rainbow of colors.
Name: Gary Coffey
Email: garycoffey12@gmail.com
📞: 224-266-7476