Episode: 1908 Title: HPR1908: Arduino Pumpkin Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr1908/hpr1908.mp3 Transcribed: 2025-10-18 11:02:03 --- This is HPR episode 1908 entitled R U E O Pumpkin, it is hosted by ROOPS and is about 7 minutes long. The summary is, ROOPS talks about how his class built a pumpkin that comes alive for Halloween. This episode of HPR is brought to you by an honesthost.com. Get 15% discount on all shared hosting with the offer code HPR15, that's HPR15. Better web hosting that's honest and fair at An Honesthost.com. Welcome to HPR, this is DROPS and today I'm going to be talking about my pumpkin. Now this pumpkin was an idea that was found on Etsy or Pinterest or whatever, but somebody made a pumpkin that opened and closed its mouth and it was all electronicaled up and it was nerdy and it was cool. So you can see videos and photos of our project on the HPR website. So go look at them right now, go do it right now because this will make so much more sense if you go look at it first. So go look, I'll wait on you. So some of my students helped with building this monstrosity and my microcontroller class, dissected the idea and they had some better ideas for the project. Now when your students get to the point where they think they can do something cooler than you can do, then you know you're winning and they actually have sense to back this up. Now currently they're building some LCD 117 kits from modern device and are off on their own little awesome world of saying hi and getting things to work when they come into class and it's nice just to sit back and watch them go. So for this project we reused a Perth board from an old project and a really bare bones board from modern device. That RBBB or really bare bones board is a really cheap way to add an Arduino clone to a project. Now there are some smaller ones, there are some cheaper ones, but I like to be able to pull off the chip and from the project and so having that RBBB is really handy. Now first we set about making sure that we could open and close the mouth of the pumpkin. In this project we were emulating, they used a servo to open and close the mouth, but servos are expensive, especially when you're putting inside a nasty pumpkin that's going to rot. And last year my junior high class took apart some old VCRs which was awesome like we spent, like a week taking apart VCRs and googling parts and seeing how things worked and they didn't really know what those were. So we had a bunch of motors left over that had some large gears attached and thought that would be a handy way to do things. So we drilled a hole in the gear and we were able to add a code hanger. Now for the record code hangers or almost as handy as electrical tape which obviously we also used. And we used this code hanger to lift the top of the pumpkin up on each rotation of the gear. Now I forgot to really talk about the pumpkin. I cut it like a kind of a Canadian from South Park kind of way which is to say that all way around in the middle and with big sharp teeth like really tall teeth. And this is the clever bit and I didn't come up with that at all but it's what made this project click in my head because having these big tall teeth when you it allows you to raise the top and drop it with the appearance of it biting and it falls right back into place because of the nice big teeth. So thank you internet stranger for this awesome idea. Now I'm trying to find this project again and I came across a bunch of others that trying to solve this problem and that did and many were using a hinge that they cut out and I'm going to try that next time but the teeth idea of works perfectly. So using code hangers, no I told you they were very handy. I was able to fashion some feet and that held the motor up. And the first mistake we made was that the nine volt battery that we were using to test this motor it worked great but the really bare bones board didn't have enough to run the motor and open the mouth. And so this was easy to fix. The whole project was powered by a nine volt battery so I simply used a relay to connect nine volts straight to the motor using a five volt pin on the Arduino to manipulate the relay. Now that the motor is working we had to figure out a way to turn it on and just having a switch is kind of lame so we use light to make it interactive and cool and when you have an analog value like how much light is in this room you need to have a way to adjust this level. So in this case we used a knob or a potentiometer and that worked just fine so we were able to set a threshold of this is what this room is like so we could carry it out of the school and have it operate. And so we wired those up we threw in a couple LEDs for eyes and we started to code. So Arduino programming is as complicated as you want it to be. There's two required functions I don't even maybe not even required the loop we probably want but anyway the two main functions that most Arduino programs use is set up in loop. Setup gets everything ready and it runs once and loop is that's where everything repeats itself forever or it's all a loose power or till you tell it to stop. So in the setup we tell the Arduino which pins will be inputs and which ones will be outputs outputs the stuff like turn the motor on and off or turn the LEDs on and off and input reads the potentiometer or and reads the light sensor. So this program which is included on the HPR site where you should have already gone to look up videos and pictures it kind of flows like this. When the pumpkin device starts it sets up the pins as input and output and it goes directly into the loop. In the loop it checks the potentiometer to see the sensitivity that we've set for the device. Next it reads the light sensor or photo diode if you're all nerdy like that and it compares that value with the the sensitivity value of the potentiometer or the knob. Now both of these inputs are analog and the Arduino sees them as a value between 0 and 1023. If the light sensor is below the sensitivity value which means the lights are off the pumpkin animates and it comes alive. Now to animate we're simply sending five volts to the LEDs to turn on the eyes and the relay connected to the motor also gets five volts and it waits about a tenth of a second before cutting off the power and then the loop repeats itself and it checks the potentiometer the light sensor and it decides whether to animate or not and this continues until the power is cut or we send new sketchs that are do we know. Now could this be done better? Totally. Maybe have the eyes faded in and out that'd be kind of cool. Maybe you have it play sounds. Now maybe put some lights inside of the thing so when you turn the lights off like the mouth of the glows but then you've got all your motors and code hangers electrical tape all hanging out in there. Now this is the best part about a project like this is that you can make it your own. We had a lot of fun building this project and I hope that you get an idea from this and say oh snap I can do it so much better than they did it. Anyway I'm Drupes and this was HPR. You've been listening to Hacker Public Radio at Hacker Public Radio dot org. We are a community podcast network that releases shows every weekday, Monday through Friday. Today's show like all our shows was contributed by an HPR listener like yourself. If you ever thought of recording a podcast then click on our contributing to find out how easy it really is. Hacker Public Radio was founded by the digital dog pound and the infonomican computer club and is part of the binary revolution at binrev.com. If you have comments on today's show please email the host directly leave a comment on the website or record a follow-up episode yourself on this otherwise status. Today's show is released under Creative Commons Attribution Share Light 3.0 license