Ishaant Nandu

Breath Exerciser

Abstract

Breath exercises have any health benefits. They can help improve lung function, reduce stress, and relax the body. Some of these are 3 S-R-B and Box breathing. While all these exercises require the use of mobiles to play tracks, it might make you more anxious. Thus, I have made a simple Arduino-based exerciser that can be used to perform these exercises using visual and auditory cues.

Requirements

You can get all these supplies here as the links above have too many items than required. This is absolutely not sponsored, I just found these on Amazon

Wiring

Pin on Arduino Circuit component
Pin A1 Positive leg of green LED
Pin A2 Positive leg of red LED
Pin A3 Positive leg of buzzer
Pin A0 Middle leg of potentiometer
Pin D10 Left pin of first button
Pin D7 left pin of second button
VCC (or 5V) Left leg of potentiometer
GND Right leg of potentiometer, all the negative legs of the LEDs and Buzzer, all the right pins all buttons

The code

#define b1 10
#define b2 7
#define l1 A1
#define l2 A2
#define bz A3
#define tp A0

int time=400;
int count = 1;
int mode = 0;

void setup() {
  // Initialize Serial Communication
  Serial.begin(9600);
  Serial.println("--- System Initializing ---");

  pinMode(b1, INPUT_PULLUP);
  pinMode(b2, INPUT_PULLUP);
  pinMode(l1, OUTPUT);
  pinMode(l2, OUTPUT);
  pinMode(bz, OUTPUT);

  Serial.println("Waiting for button press to select mode...");

  // Wait for a button press
  while(digitalRead(b1) ==1 && digitalRead(b2) ==1) {
    delay(100);
  }

  // Determine Mode
  if (digitalRead(b1) == 0) {
    mode = 1;
    Serial.println("Mode 1 Selected (Button B1)");
  } else {
    mode = 2;
    Serial.println("Mode 2 Selected (Button B2)");
  }
}

void loop() {
  // Debugging: Print current status to Serial Monitor
  Serial.print("Mode: ");
  Serial.print(mode);
  Serial.print(" | Count: ");
  Serial.println(count);

  if (mode == 1) {
    time=1000;
    if (count <= 3) {
      digitalWrite(l1,1);
      digitalWrite(l2, 0);
       tone(bz, 500);
    }else {
      digitalWrite(l1, 0);
      digitalWrite(l2,1); 
       tone(bz,450);
    }
     if (count ==5) {
      count = 0;
      Serial.println("Count reset to 0");
    } 
  } else{
    if (count<=4){
      digitalWrite(l1,1);
      digitalWrite(l2, 0);
       tone(bz, 500);
    }else if (count>=9 && count<=12){
       digitalWrite(l1,0);
      digitalWrite(l2, 1);
       tone(bz, 450);
    }
    else{
       digitalWrite(l1,0);
      digitalWrite(l2, 0);
    }
     if (count ==16) {
      count = 0;
      Serial.println("Count reset to 0");
    } 
     time=map(analogRead(tp),0,1023,400,2000);

  }
  Serial.println(time);
  count++;
  delay(time);
  noTone(bz);
}

The way it works

It keeps a controlled time period called count. Based on the count we can know what time to make the green/ red light turn on/off.

Usage

There are 2 modes, 3-S-R-V and Box breathing. One button will turn on one exercise and another will turn on another. Use potentiometer to control time. During the exercise, red light is for exhallation, green is for inhalation and no light is holding breath. Press the reset button on the microcontroller to stop the exercise, and breathe normally, regardless of any light.