Boo!!! I’m not a pumpkin!
midterm project of : Firm Tharit Tothong
project name : Boo!!! I’m not a pumpkin!
This pumpkin take a character like a ghost in Mario game. (this guy )
Basically, the idea is the pumpkin going to do something when you’re not there.
Initial ideas now are to use proximity sensor to detect people and it hide itself if there is someone there, while it casually lit up when nobody nearby.
Also, it make some sound this sound is refer to Ghost house theme in Mario game and the beat is an analogy of the heartbeat of Boo. So when no body is closed to it, the beat goes slow because it’s relax. And goes more upbeat if there is someone nearby.
#include "pitches.h" int speaker = 5; int bulb = 6; int lightPin1 = 3; int lightPin2 = 4; int brightness = 0; int fadeAmount = 5;</code> // notes in the melody: int melody[] = { NOTE_B3, NOTE_CS4, NOTE_A3, NOTE_C4, NOTE_B3 ,NOTE_CS4, NOTE_A3, NOTE_C4}; // note durations: 4 = quarter note, 8 = eighth note, etc.: int noteDurations[] = { 4, 4, 4, 4,4,4,4,4 }; void setup() { pinMode(speaker, OUTPUT); pinMode(bulb, OUTPUT); } void loop() { note(); fade(); } void note(){ for (int thisNote = 0; thisNote < 8; thisNote++) { // modulate music speed through proximity sensor int tempo = map (analogRead(0),10,400,300,4000); int noteDuration = tempo/noteDurations[thisNote]; tone(speaker, melody[thisNote],noteDuration); int pauseBetweenNotes = noteDuration * 1.30; delay(pauseBetweenNotes); // stop the tone playing: noTone(speaker); } } void fade(){ int brightness = map (analogRead(1),10,250,10,255); analogWrite(bulb, brightness); }
Reply