Control a Cockroach With Arduino for Under $30

Introduction: Control a Cockroach With Arduino for Under $30

I'm16 and in my free time I control cockroaches, weld, make canoes from duct tape, 3D print, make...

A few years ago I saw Backyard Brains' smartphone controlled cockroach, and it just blew my mind! I tried to get my mom to let me buy it, but the mention of cockroaches convinced her otherwise. :) I started doing projects with the Arduino a few years later. I remembered how much I wanted to do the cockroach experiment, so I convinced her that cockroaches weren't gross at all. Then I ordered a couple of Madagascar Hissing Cockroaches. Once they arrived, I started coding, testing, recoding, retesting. Finally I found out how to do everything right and temporarily change the cockroach's behavior as you will see in this video:

This is not a toy it is a scientific experiment to teach neuroscience. It is similar to someone getting a cochlear implant (which has returned hearing to more than 324,000 people.) Cockroaches can regenerate lost antennae and limbs. The cockroaches in this project were fully anesthetized during the “surgery.” Everything I did is reversible and was reversed at the end of the experiment. Also, I used Cyanoacrylate (super glue) in this project but it isn’t harmful because a similar chemical was used in the Vietnam War to seal wounds on humans.

Step 1: How It Works

How does it work you ask? Well as do many insects, cockroaches have antennae which are directly involved in navigation. By stimulating the antennae with variable frequencies (that mimic neural signals) from the Arduino you can make the cockroach think that there is a wall in front of it when there isn't. When that happens the cockroach turns in another direction. Although after a while the cockroach starts ignoring the stimulus and continues walking as if it didn’t have the backpack.

Step 2: Materials


  1. Arduino Micro $20
  2. 12V A23 battery $2
  3. A23 battery holder (or some aluminum to make your own)
  4. Pin connector
  5. Thin wire (I got mine out of some stranded wire) $1
  6. Super glue(cyanoacrylate) $2.48
  7. Your choice of non-toxic glue 90 cents
  8. Sandpaper
  9. Small washers


  1. Madagascar Hissing Cockroaches (⚠ Before you buy, check your country and states regulations ⚠)
  2. Large fish tank
  3. Small fish tank
  4. Bananas, apples and dog food (feed the cockroaches this everyday with a wet paper towel)
  5. Egg cartons (use these as hiding spots for the cockroaches)
  6. Cut up paper (use this as bedding in the terrariums)
  7. heat pad

Make sure to check your country and states regulations on cockroaches. Always keep their cage shut and with a thick layer of petroleum jelly around the top. NEVER leave cockroaches unattended out side of their terrarium and NEVER EVER release cockroaches into nature where ever you live.


  1. Soldering iron
  2. Straight pin
  3. Hot glue gun
  4. Scissors
  5. Box cutter
  6. Lighter or matches (for burning super glue off if a wire comes out)

Step 3: Build the Backpack

The first step is making the “backpack.” Using some sheet aluminum cut out a 3in x 2in “+” shape. Then bend the edges up (see pictures.) If they break off try cutting against the grain of the aluminum. After that, wrap electrical tape around one of the ends. Next, drill a small hole on one of the ends toward the middle, and insert the wire through. Then solder one of the ends to a small washer. Do the same to the other side. Once you are done with that, solder a pin connector to the wires you just installed, and put electrical tape on the solder joints. Next, hot glue a bigger pin connector to one of the sides of the "backpack", solder an approximately 1 inch long wire from the stranded wire to one of the pins, and do the same with the other pin. Also, if you want to test it put an A23 battery into the holder and put the pin connector into the Arduino Micro's VIN and GND pins. If it lights up you did it right. If not you might need to bend the battery pack so it touches the A23 battery.

Step 4: Antennae Procedure

Take a cockroach and gently put it in a cup of ice water
(this anesthetizes the cockroach) for approximately 2 minutes or until there is little or no reaction to movement. After that lay the cockroach on your paper towel and lightly sand the top of the cockroach's thorax (this is a nerve-less substance much like your finger nails and hair) then with your non-toxic glue, glue the backpack to the sanded area. Next, trim the antennae down to about 2-3 cm. After that, lightly insert the wire about 1/4 cm into one of the trimmed antenna (which is hollow) then apply some of the super glue onto the wire and push it another 1/4 cm into the antenna, do the same with the other antenna. Almost there! Before continuing make sure the cockroach is still fully anesthetized, if not put him gently back into the ice water. Carefully insert the straight pin into the side of the cockroach's thorax. Next, insert the ground wire 1/4 cm into the small perforation you just made, and apply a small amount of super glue onto the wire and insert it another 1/4 into the hole. Make sure the wires are away from his legs because they can pull the wires out! When you are done let him recover overnight in a separate terrarium. Once you've done the surgery a couple of times it gets easier. Also, remember to clean off the table and dispose of the ice water to keep your mom happy.

Step 5: Code

The code is simple and easy to modify. If you try to rewrite the code remember to use noTone(your pin# here) after every time you use the tone function. Also, Arduino uses milliseconds so 1 second equals 1000 milliseconds. If you want to stimulate the other antenna simply change 11 to 12.

/* void setup() {

void loop() {

  tone(11,random(1,100),random(1,1000)); //this will make the cockroach turn in one direction

Step 6: Try It Out!

Once you've uploaded the code to the Arduino, take the cockroach with the backpack out of its terrarium, insert an A23 battery into the backpack, put the pin connectors into the Arduino and watch the cockroach turn! If you suspect it isn't properly grounded get out a voltmeter and set it on ohms. Put a lead on the antenna wire and one on the ground wire, if it reads anything above 1 ohm you've done it right, if it reads below 1 the antenna wire and the ground wire are touching, and if it reads “out of range” it isn’t grounded properly so you will need to redo the procedure for the ground wire. Once you are done with this experiment, remember to gently remove the backpack and cut the wires off. Another tip, when testing it out make sure to do it in a room where the lighting is generally the same because the cockroaches sometimes turn in darkened areas.

A special thanks to my mom who put up with having live cockroaches in the house and to my dad for providing help with the project. Thanks for reading!

2 People Made This Project!


  • Water Contest

    Water Contest
  • Metalworking Contest

    Metalworking Contest
  • Fix It! Contest

    Fix It! Contest

24 Discussions

you might have noticed I entered this project in a few contests so if you like it just hit that vote button and select the contests!

Any insight on how to make its movements more methodical? Which range of tones will cause a turn?

what did you use to control its movement?

it looks very cool me and my friends have yet to try it but i cant wait

In case you didn't notice - it is a COCKROACH, not a baby panda.

Also, they're not exactly an endangered species...

Neither are humans an endangered species. Maybe you should try it on a human next time. I like your logic.

Hey, maybe he should.

Except, you know...'s illegal.

Neither are people, does that mean we should be cruel to people?

Have you ever thoughtlessly eaten an innocent animal? killed spider? Yeah, me too. This doesn't seem so bad. Also it is probably far more complicated to test it on humans.. That being said if you volanteer - I would be happy to give it a go.

Wow..! i did hate roaches, but from now i look at them as living Arduino shields !! xD

Its hard for me to order Madagascar Hissing Cockroaches in my country. Can we use other types of cockroaches? Can the ones I find in the corner of my house work too?

1 reply

they should work but they need to be big enough for the backpack to fit on

Have you considered using an ATtiny for this project? That is a large roach and seems to be able to carry pretty heavy loads, but if you could follow these instructions from MIT's High-Low Tech page and use your code on a tiny, it might make it easier on your little friend.

1 reply

thanks but I'm not familiar with the ATtiny. On the page you linked to in the list of working functions it doesn't say that the tone() function works. Also, if a hissing cockroach were a person it would be able to lift thousands of pounds.

thanks for the comment!

In the movie "5th element" there is a thing like that

(a spy roach)

I think step four is wrong, as it has the same discription as step three. or could the problem be with my device

1 reply