Close

Value gun - a racist gun that senses skin color (doesn't actually)

A event log for Hackaday World Create Day Lithuania

At Internet of Shit hackathin, Vilnius

aryaArya 05/12/2017 at 15:460 Comments

Value Gun is a project that was created at Internet of Shit hackathon, a hackathon where people went to create the most useless or the most technologically harmful connected devices. In the same room as vaping machine controlled by Amazon Alexa, smoke detector tweeting pictures of fire instead of sounding alarms, and a rotary phone you could use as a Bluetooth keyboard, there were two guys designing and building a gun tht would detect a person's skin color and give directions on whether to shoot that person or not.

I was the guy responsible for the electronic side of the gun. When I came to the hackathon, I remembered I had bought a Chinese RGB sensor breakout from eBay, and I was thinking about finally getting to play with it, so originally I pitched an idea of connected diapers, even describing my wish for a worldwide network of connected diapers that could paint the global map in different shades of brown. However, I was soon after approached by another guy, who had the "racist gun" idea, and so I went with it =)

The concept is simple - there's a sensor that can determine the color of the object in front of it, essentially an one-pixel camera. By taking data from that pixel, we're likely to receive something that might be classified as a color of object before the sensor - once the result is filtered, averaged and the value is checked for sanity. Of course, conforming with the "Internet of Shit" designation, we weren't going to do any of that and so it would be as straightforward as possible. We went to the store, picked the first toy gun we found (not exactly a stereotypical Glock, but this will do) and started hacking.

The idea is obviously a dig at current situation in America, as it's presented in American media and subsequently interpreted by people. I think most people have heard about George Zimmerman and Trayvon Martin controversy, as well as all the statistics that support or refute the point that people of color are discriminated against by both police and ordinary people, often resulting in deaths and wrongful convictions. Moreover, it's a dig at the American gun culture stereotypes, as well as stereotypes about street gangs.


I picked a Wemos D1 Mini board, with an ESP8266 module onboard, since it was the board we had that supported MicroPython, and I love MicroPython so I try to use it whenever possible. Besides, ESP8266 has WiFi connectivity, and MicroPython has OTA upgrades over network - I weren't going to use any of that, but it would be a benefit when telling about the device - obviously, if the gun can send statistics over the Internet, or - even better - can be easily tweaked by a hacker, it's a bonus point. With the MCU decided on, I built a quick&dirty prototype, linking the sensor and Wemos board with pretty colored wires, which also kinda worked as structural support of the gun add-on.

Early on, we thought we could have voice playback - unfortunately, I understood that it would actually need some effort to be implemented, and "effort" wasn't on my TODO list for the weekend. Instead, we just picked an RGB LED and decided to use it as skin color indicator, "red" would most likely mean "shoot immediately" and "green" would mean "do not shoot". We also considered adding an accelerometer sensor to determine orientation of the gun - if it were to be held sideways, we could possibly change color ranges used as "shoot" and "no shoot" colors. Unfortunately, even though I was searching for it for half an hour, I couldn't find an accelerometer in my bags of electronic crap I brought to the hackathon.

We decided that the "determine color" routine would only need to be run when the trigger is half-pressed. I had a small pressure-sensitive resistor with me, and I attached it to the only analog port of ESP8266. Unfortunately, for some reason the values it gave were noisy and hard to map to any reasonable range of values I could use to determine if there's pressure on the resistor. I understood I would need to measure and calculate resistor values for the voltage divider in order to get a reasonable voltage range. Instead, I only connected one wire of the resistor to the ADC, leaving the second wire unconnected, which, through capacitative coupling with human body, would result in high levels of noise on the analog channel, basically turning the resistor into an antenna, and left a simple "value higher than 20 out of 1024" condition in the code. This had a funny side-effect of the measurements being triggered randomly, all the time when the resistor was in contact with the hand holding the gun, but we weren't going to be deterred by that.

This was the way the first day of the hackathon ended.


On the second day, I set on to make the RGB sensor work. Before falling asleep, I found a 2000-lines-of-code C library that would work with the sensor I had. However, I was using Python and wasn't going to change it, so I decided to try and convert most of the C code into Python using regular expressions. This, not incidentally, was the way I fell asleep, and upon waking up I shaked my head, horrified by just what the hell my brain has suggested the previous night. I decided I should finally type "python xxxx rgb sensor library", the idea which hasn't visited me when I was searching for the library before. Lo and behold, it found something and, after loading the code on the MCU, I braced myself for all the various things I could encounter when launching it. What I found was shocking (c).

It appeared that I actually received a "proximity and ambient light" sensor, instead of "RGB and gesture sensor" designation which was indicated on the anti-static bag I received the sensor in, eBay listing heading and its description. Of course, this meant "more things to tell about later during the pitch", and I decided the gun could still work - for now, with a proximity sensor and some code-embedded sociopathy. I found the model of the sensor which I actually had, then found a Python library which was, by author's words, "tested and working". After fixing some syntax errors which'd prevent it from even being imported by any sane Python interpreter, I tried to make it work, but no dice. The sensor would give some kind of proximity value, but only in range of (128, 512, 1024, 4096), and only if re-initializing the sensor before each measurement. Having read through the datasheet a couple of times by then, I went on and deleted all the sensor-related code from my main.py, replacing it by MicroPython's analog of random.randint() - it was 30 minutes before the final pitch.

#TODO - find and post code I used for the gun


What we got in the end was a gun which would give "shoot"/"no shoot" directions, directed by whatever randomness source the MicroPython core uses. I think we made an "unbiased gun" instead, giving everybody, regardless of their skin color, a fair chance. Anyway, we speculated a bit more and concluded that, with some kind of sound or vibromotor addon, it'd be a great weapon for blind American policemen. We were really disappointed it wouldn't make sounds - we had quite a lot of suitable sound samples we could have used. All of that sounds like great suggestions for v2 of this gun, in the extremely unlikely chance we ever work on it. If you unironically like this project's idea and would want to see this implemented, please get yourself checked or something - otherwise, I hope it was a fun read about building useless tech for fun.

Obligatory pile of components and wires

Discussions