Category Archives: Stupid Pet Trick

Sound Sensor

I bought a electret mic breakout to make a sound sensor. The input and output are both in analog form. It doesn’t show up that well on camera but it works, however I would like to experiment more with delays so the LED lights up for a longer time. It is also not very sensitive to small changes in sound.


Stupid Pet Trick

For this assignment, I wanted to create a circuit where pressing a button a certain way would result in a certain color of light emitting from the 3-color LED. This was another adapted attempt of the same project from the book that I tried last week. I wanted to make it so that the light in would be shine blue constantly and pressing the button would result in either a red or green color emitting from the light. The red would be the ‘wrong’ sequence of button presses and the green would be the correct sequence. I thought that this idea was simple and possible, but I really didn’t know how to achieve it.

I started by setting up the breadboard similar to that of the one from the project in the book. I added the button and tried to remember exactly what we did the last class when we used the button.

I couldn’t remember and found a tutorial online that could help guide me. After then, I tried to figure out how to make the red or green light shine when the button was pressed in different ways. After running my idea by a friend, she said that timing things was tricky, so I modified my idea to simplify it a bit. I decided that holding down the button for a certain time should be easier to program than than a certain sequence of presses.

I looked online for a reference and tried to adjust some code to fit my idea for the project. In reality, I had no idea what I was doing and was a bit unclear of which things I needed to change or be mindful of to make the project work the way I wanted it to. At one point, I pressed the button and the green light shone, but then remained on for as long as the arduino was connected to power. I wasn’t able to turn it off by pressing the button or to make the light shine red or blue again.

Here’s my gitHub code.
And here’s the bit I soldered.


Kind of a Small Theremin- Eleni Giannopoulos

I’ve always thought theremins were super cool and I would say their whole concept is pretty ridiculous as far stupid pets tricks go. A theremin is an instrument that you play without touching. There’s a rod that senses how close your hand is and raises and lowers the pitch being projected based on distance.  I guess you could play pretty much anything but they sound wild so they’re mostly used for old sci-fi type sound effect. Think about the standard “an alien just appeared” noise and that’s probably a theremin.

Mine is a little different. I used the ultrasonic sensor that came with my kit and detects distance. It uses an echolocation type process so to get the best result you have to have a flat surface directly in front of it. It regularly sends out an ultrasonic wave an measures how long it takes to bounce off the nearest object and return.

I used a conversion to read that number in inches and then assigned the different measurements a tone to play out of the speaker I hooked up. So if the object was 2 inches away the speaker would play a low sound but i it suddenly moves to 4 inches away it would play a slightly higher sound.

True theremins have continuously changing pitches, which is what gives them their funky vibe, but when I tried used a map function to get this happen with my own I didn’t like the resulting sound. My ultrasonic sensor reading wasn’t steady enough I think, so the tones kept jumping back and forth like crazy.

I stuck with certain tones at certain distances and tuned the instrument by looking up the hertz associated with various notes in a scale. I gave a it range of c4  all the way to a5 on an F major scale (no chromatics) and I made a little paddle out of a playing card to give the sensor a flat surface and a steady reading.

It’s still a little glitchy, flickering between notes, but I can now play some songs. My set list includes:
auld lang zyne
amazing grace
hey jude
loch lomond
my heart will go on
home on the range
danny boy
oh susanna
red river valley
the chorus of american pie
a barely recognizable version of total eclipse of the heart
christmas medley
2 really old greek songs
a not as old greek song
that one well known opera song

So basically everything you’d wanna hear at a concert.

Here’s the code:

Here’s me playing that one well known opera song;

Stupid Pet Trick

For this week’s assignment, I wasn’t sure exactly what to solder because all the components that came with my Arduino kit didn’t need any soldering. In the end, I decided to solder some wires onto an LED because the pins on the LED are so short. I figured that having longer legs could help in future projects. I also found soldering to be very satisfying! The way the solder melts as soon as it touches the hot metal felt really nice for some reason.

For the circuit assignment I ended up making a very simple phototransistor circuit. The phototransistor detects how much light there is and adjusts the LED brightness based on that:

I reversed the mapping so that when there is little light detected, then the LED is bright. When there is a lot of light, the LED is dim. This makes more sense because we don’t need the LED to be bright if there’s already a lot of light.

Here is the code:


Assignment 3

So I started this project similar to the last one. I first made the Color Mixing Lamp from the Arduino Projects Book. Then I decided to switch out the photo-resistors for potentiometers so I could control the colors and the brightness better.  Then I decided to add a switch just to make it more like a regular light. The code isn’t that much different than my last project but it does use both analog(potentiometers) and digital sensors(the button). However for some reason I couldn’t get the timings to go off. It is supposed to turn on when you press the button and allow you to mix the red blue and green while you hold the button down. Then after 10 seconds it should blink at the color that you have picked and change if you wish to continue turning the potentiometers. Then after another 10 seconds it should start fading out then turning back on then fading out. At this point you can no longer change the color with the potentiometers. Finally after another 10 seconds it is supposed to turn to red. I was sort of seeing if I could turn my project from last week into one with just one LED and more sensors. In the video I put a small piece of paper over the LED just to make it easier to see the color of the lamp. Since the timing wasn’t working I wrote smaller blocks of code in different sketches to show what it would look like had it worked.

The potentiometers are connected in parallel to the power source through the switch which is why they don’t work and the light doesn’t turn on unless the button is pressed. I connected them in parallel so they would get the same amount of voltage. I could have put the resistor in series with the button, but I had added the button near the end, so I forgot to simplify the circuit as I went, but it would make it look less complicated, it still has the same functionality though.

Here’s the link to my code.

Color Mixer

I soldered leads to the piezo buzzer included in the Arduino starter kit because the pins on the buzzer itself are too short and the component takes too much room on the breadboard if plugged in by the pins.

Soldered Piezo Buzzer

For my Stupid Pet Trick, I made a color mixing LED with analog input and output by modifying the fourth project from the Arduino Projects book. I substituted the phototransistor inputs with potentiometers to allow users to manually adjust the amount of red, green, and blue light the LED emits.


View post on

View post on

View post on

View post on

View post on

View post on

View post on

Variable Strumming Pattern Ukulele Strummer

This week I wanted to do something musical as my “Dog Trick” I though about what I’d learned about analog inputs and using them with digital outputs and wanted to do something with something other than an LED. I tested out the motor and found it worked, but I couldn’t adjust the spinning speed without a transistor. I got the idea to use the motor at intervals to create strumming patterns for my ukulele that would change based on the input of the potentiometer. Using this I set up 3 states that the motor could be in, a delay of 80 millis and another of 400 millis. These provided rather different strumming patterns. I also created an option for the motor to be fully on. Using these I can play various songs with different moods based on the speed of the track.

The sketch can be found here

A video of it in action

A picture of the setup

I’ll demonstrate with a song or two in class

Stupid Pet Trick – Whack a Mole

I wanted to make some kind of a game for the stupid pet trick assignment, and I’ve decided to make a whack-a-mole.

The rule is simple.

  1. You whack the LED “mole” with the joy stick. When you miss 5 moles in a row, it’s a game over.
  2. You can see the score on top of the bread board. This will tell you how many moles you have missed. When you whack a mole, it resets after flashing.
  3. You can change the speed (difficulty) of the game by turning the potentiometer. It gets impossibly difficult when you turn it all the way.


Here is a video of the game.

The code looks like this.


here is the soldered potentiometer.

Stupid Pet Trick — Let’s Disco!


As shown above, I have made a speaker that is controlled by the amount of light that it receives. Bonus: I have found the perfect filter on YouTube for my project!

Once again I am using phototransistors as analog inputs, one of them controls the pitch of the sound and the other the duration. This way we get an instrument that can be controlled with both hands of the user. It is interactive and it provides hours of fun, although the square wave form will quickly give the audience a headache.