生日蛋糕 Arduino Birthday Cake

用LED模擬蛋糕的蠟燭

Simulate candle with LED

Extinguish the "candles" on the cake

Using hc-sr04 ultrasonic sensor to measure the length between the candles and our face, so when our face gets close to the ''candles'' it will extinguish.

Video link:

https://www.youtube.com/watch?v=sAMIqvHFJSA&feature=youtu.be

Step 1: Materials 材料

For circuit(電路):

Arduino Leonardo*1

solderless breadboard*1 (麵包版)

wires*30 (電線數條)

220 Ohm resistor*2 (220 ohm電阻 )

LED*2 (LED燈)

1602 LCD*1 (LCD液晶螢幕)

hc-sr04 ultrasonic sensor*1 (超音波感測器)

For cake (蛋糕裝飾):

Clay (黏土)

Foil bowl or paper bowl (鋁箔碗或紙碗)

A box for cake*1 (用來裝蛋糕的紙盒)

A4 paper for decoration (A4紙)

Step 2: Connected Circuit & Code (接電路&程式碼)

1.I recommend using a wire to extend the length of the LED light.建議再用公母頭的線將LED加長( It's easier to put them in the cake)

2.It is UNO in the circuit picture, but it is suitable for LEONARDO. 此電路圖為UNO板,但適用於LEONARDO板。

Code (程式碼):

<pre><p>#include <br>#include 
</p><p>// For these LCD controls to work you MUST replace the standard LCD library from...
// https://github.com/marcoschwartz/LiquidCrystal_I2C
// Direct download https://github.com/marcoschwartz/LiquidCrystal_I2C/archive/master.zip
// Your project will not compile until this is done.
//
LiquidCrystal_I2C lcd_I2C_3F(0x3F,16,2);
int ardublockUltrasonicSensorCodeAutoGeneratedReturnCM(int trigPin, int echoPin)
{
  long duration;
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(20);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  duration = duration / 59;
  if ((duration < 2) || (duration > 300)) return false;
  return duration;
}</p><p>void setup()
{
  lcd_I2C_3F.init ();
  lcd_I2C_3F.backlight();
  digitalWrite( 6 , LOW );</p><p>  pinMode( 12 , OUTPUT);
  pinMode( 11 , OUTPUT);
}</p><p>void loop()
{
  lcd_I2C_3F.clear();
  lcd_I2C_3F.setCursor(0.0 , 0.0) ;
  lcd_I2C_3F.print( "Happy Birthday" );
  lcd_I2C_3F.setCursor(0.0 , 1.0) ;
  lcd_I2C_3F.print( 	ardublockUltrasonicSensorCodeAutoGeneratedReturnCM( 6 , 7 ) );
  delay( 500.0 );
  if (( ( 	ardublockUltrasonicSensorCodeAutoGeneratedReturnCM( 6 , 7 ) ) > ( 20.0 ) ))
  {
    digitalWrite( 12 , HIGH );
  }
  if (( ( 	ardublockUltrasonicSensorCodeAutoGeneratedReturnCM( 6 , 7 ) ) < ( 20.0 ) ))
  {
    digitalWrite( 12 , LOW );
  }
  if (( ( 	ardublockUltrasonicSensorCodeAutoGeneratedReturnCM( 6 , 7 ) ) > ( 20.0 ) ))
  {
    digitalWrite( 11 , HIGH );
  }
  if (( ( 	ardublockUltrasonicSensorCodeAutoGeneratedReturnCM( 6 , 7 ) ) < ( 20.0 ) ))
  {
    digitalWrite( 11 , LOW );
  }
}</p>

Step 3: Start to Make Your Cake !!! (做蛋糕)

1. Drill two holes in the bowl (for inserting candles).

2. Cover the bowl (cake) with clay and add your favorite decoration.

3. Cover the connected LED with paper. (candle)

4. Insert two candles into the cake. (as the picture shows)

1. 把碗鑽兩個洞 (用來插蠟燭)。
2. 用黏土包覆碗(蛋糕)然後加入自己喜歡的裝飾。

3.用紙包覆接好的LED。(蠟燭)

4.把兩個蠟燭插入蛋糕內。(如圖所示)

Step 4: Final Step (要完成了)

1. Put it in the box (放到盒子裡)

2. Stick ultrasonic sensor on the top of the box (the box you put your cake), so when you pull out your cake, the ultrasonic sensor can measure the length between the face and candles. (把超音波感測器黏在箱子上,它就可以測量臉跟LED的距離,蠟燭就會在一定的距離熄滅。)

3. You can stick the LCD on the top of the box, so it can shows "happy Birthday'' (把LCD液晶螢幕年在盒子上就可以顯示生日快樂)

Your birthday cake was served...(你的蛋糕完成)

CITATIONS

£3.35 40pcs 20cm Female to Female Jumper Cable Dupont Wire For Arduino Arduino Compatible SCM & DIY Kits from Electronics on banggood.com
"£3.35 40Pcs 20Cm Female To Female Jumper Cable Dupont Wire For Arduino Arduino Compatible SCM & DIY Kits From Electronics On Banggood.Com." www.banggood.com. N. p., 2019. Web. 2 June 2019. Arduino Leonardo with Headers "Arduino Leonardo With Headers." Store.arduino.cc. N. p., 2019. Web. 2 June 2019. Ultrasonic sensor HC-SR04 Philippines "Ultrasonic Sensor HC-SR04 Philippines." Makerlab-electronics.com. N. p., 2019. Web. 2 June 2019. Breadboard | Arduino Lesson 0. Getting Started | Adafruit Learning System "Breadboard | Arduino Lesson 0. Getting Started | Adafruit Learning System." Learn.adafruit.com. N. p., 2019. Web. 2 June 2019. 220 Ohm 1/2 Watt 5 % Carbon Film Resistor (5-Pack) "220 Ohm 1/2 Watt 5 % Carbon Film Resistor (5-Pack)." RadioShack. N. p., 2019. Web. 2 June 2019. Bulbs, L., Flashlights, L., Lights, L., Lamps, L., Lights, L., RGBs, L., Watches, L., Kit, E., LED, S., Components, E., LED, S., Components, S., 5mm, L., LED, W., Bulk, L. and MORE, M. Bulbs, LED et al. "LED Components | Ebay." eBay. N. p., 2019. Web. 2 June 2019.

Share

    Recommendations

    • Beauty Tips Contest

      Beauty Tips Contest
    • 1 Hour Challenge

      1 Hour Challenge
    • Sensors Contest

      Sensors Contest

    2 Discussions