Site icon Making Studio

Tong’s Final Project

When you want to build a habit or achieve a goal, you can use this box I designed to help! Our box has 7 switches, and each day you complete a task, you can flip one switch. After successfully completing tasks for 7 consecutive days, the box will release colorful confetti to celebrate! It encourages you to cultivate your habits in 7-day cycles.

Video

Mode

Here’s how the circuit works:

7 Switches: Each switch corresponds to an LED. When a switch is toggled, it lights up the respective LED, indicating that the task for the day is completed.

UNO Board: All switches and LEDs are connected to an Arduino UNO board, which monitors the status of the switches. The Arduino ensures the logic for tracking task completion across the 7-day cycle.

Electromagnet: The electromagnet is also connected to the Arduino. When all 7 switches are toggled (indicating the completion of the 7-day cycle), the UNO board cuts power to the electromagnet, causing it to lose its magnetic hold and release the iron piece attached to a balloon. This action releases colorful confetti to celebrate the achievement.

Here is my code:

int celebrationState = false;
int previousCelebrationState = false;

void setup()
{
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(8, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);
pinMode(11, INPUT_PULLUP);
pinMode(12, INPUT_PULLUP);

pinMode(4, OUTPUT); // 控制EG的引脚

digitalWrite(4, HIGH); // 默认保持EG通电

Serial.begin(9600);
}

void loop()
{
bool sunday = digitalRead(12);
bool monday = digitalRead(11);
bool tuesday = digitalRead(10);
bool wednesday = digitalRead(8);
bool thursday = digitalRead(7);
bool friday = digitalRead(6);
bool saturday = digitalRead(5);

// 检查所有灯是否亮了(所有输入为LOW)
if (sunday == LOW && monday == LOW && tuesday == LOW && wednesday == LOW && thursday == LOW && friday == LOW && saturday == LOW) {
celebrationState = true;

if (celebrationState == true && previousCelebrationState == false) {

  // 切断EG电源
  digitalWrite(4, LOW);
}

} else {
celebrationState = false;

digitalWrite(4, HIGH);

}

previousCelebrationState = celebrationState;
}

Instructables Link

https://www.instructables.com/HabitSpark-7

Exit mobile version