HabitSpark 7

by Tong88 in Living > Health

34 Views, 1 Favorites, 0 Comments

HabitSpark 7

截屏2024-12-11 上午4.06.10.png


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.

Supplies

Required Materials for the 7-Day Habit Box:

  1. 7 x 5mm LED Lights
  2. 7 x ON-OFF Toggle Switches
  3. 1 x 5V Electromagnet
  4. 1 x Balloon
  5. 1 x Arduino UNO Board
  6. Electrical Wires
  7. 1 x iron piece


3D Printing All Required Parts

截屏2024-12-11 上午4.20.29.png
截屏2024-12-11 上午4.20.42.png

3D Printing All Required Parts

Connect the Electronic Components on the Uno Board As Shown.

截屏2024-12-11 上午4.25.29.png

Replace the servo motor in the diagram with an electromagnet. The electromagnet has two wires: connect one wire to the ground line and the other to pin 4.


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;
}

After Confirming That There Is No Problem With the Originals, Weld All the Originals

截屏2024-12-11 上午4.25.39.png


Install the Balloon, Iron Piece, Switches, Wires, and Electromagnet in Their Respective Positions.

截屏2024-12-11 上午4.40.25.png
截屏2024-12-11 上午4.40.34.png
截屏2024-12-11 上午4.40.42.png

Great Job! 🎉