Picture of Arduino King Cobra Game
When is the last time that an electronic device impaled you?
For me, it had been far too long.

Enter... The Arduino King Cobra! (TM, R, Copyright, Patent Pending... not really).
I had some new parts and wanted to build something during my lunch hour recently. This is what I came up with.
I call these sessions "One Hour Hackathons". Only, it's just me, and I rarely time them, and yes, they are lonely.

Enjoy! You will find no schematics here, as I'm an artist. But you WILL find poorly shot and annotated photos! Yahoo!

DISCLAIMER: I recommend building this without the thumb-tack fangs, kids. Blood born illness is no laughing matter, and neither is a lawsuit. I hammered the end of my tack so that it was dull (spoiler, I know). Some have suggested great ideas such as a red marker nib, a sponge dipped in paint and electro-shock wires. Arguably all better than the thumb-tack. Be safe!
Remove these adsRemove these ads by Signing Up

Step 1: The Search For Serpent Parts

Picture of The Search For Serpent Parts
A list of bits and pieces required to make your wildest dreams come true:

1. One Arduino Whatever (any model should work). I used a Micro
2. One analog servo motor. Mine is a Tower Pro SG90 with 180 degree sweep
3. One PING ultrasonic distance sensor
4. One battery holder with batteries. Mine is 6V total, but Arduino recommends 7-12 volts for stability
5. A bread board or PCB for wiring
6. Wiring
7. One small zip-tie
8. One snake head
9. Some tape

Step 2: Snake Brains

Picture of Snake Brains
My snake runs on an Arduino Micro. You can use any Arduino though, just adjust your pins accordingly.
The way it works is the following:

1. Ping ultrasonic sensor reads the distance of your hands or objects in front of it 50 times per second
2. If close enough, the servo motor is rotated down towards your hand.

As the code works now, the "Cobra head" does not sit and wait for your hand to get too close, but instead it moves based on your distance. So the closer you get, the lower it drops to get you.
jrockn111 months ago

avrdude: stk500_getsync(): not in sync: resp=0x54

displays under Binary sketch size.

Having a little trouble. there is a green wire connected from pin 16 on the breadboard in front of the ping sensor connecting to positive. what purpose does this serve? Thanks for the help. everything else is hooked up accordingly. any suggestions?

my sensor has 4 pins,GND,Trig/tx,Echo/rx,Vcc. I conected my trig pin to rx and echo pin to pin 7
and it works
Whats the rx? You said that conect the trig to rx, Where is it?
Haha this is great fun
jabujavi1 year ago
haha! When cobra goes down, distance sensor takes it and he think it's your hand and starts to swing. Put a code to go up cobra without taking measures with the sensor.