Sam LeongAllie BachollNick SpaidJared Weber
Published

Bus Stop Mister

The bus stop mister helps people to stay cool during the hot summer days.

BeginnerWork in progress213
Bus Stop Mister

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1
DC Motor, 12 V
DC Motor, 12 V
×1
Gravity:Digital Push Button (Yellow)
DFRobot Gravity:Digital Push Button (Yellow)
×1
Dual H-Bridge motor drivers L293D
Texas Instruments Dual H-Bridge motor drivers L293D
×1
Resistor 1k ohm
Resistor 1k ohm
×3
5 mm LED: Green
5 mm LED: Green
×1
Capacitor 10 µF
Capacitor 10 µF
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

makeathon.ino

C/C++
This is the code that drives the motor attached to the flap on the side of the bus stop.
// Bus Stop Mister
// Control Code
// Authors: Nicholas Spaid, Jared Weber

// Pin numbers
const int motor_clockwise = 5;
const int motor_counterclockwise = 6;
const int button = 8;
const int green_led = 11;

// Timer nonsense
const int open_stop_time = 165;
const int shower_time = open_stop_time + 2500;
const int close_stop_time = shower_time + 155; 
unsigned long timer = 0;
unsigned long current_timer = 0;

// State machine
const int opening = 1;
const int idle = 0;
int state = idle;   

// Button states & debouncing
int current_button_state;           
int previous_button_state = LOW;
unsigned long time = 0;
unsigned long debounce = 200UL;

// Declare inputs and outputs
void setup() {
  pinMode(motor_clockwise, OUTPUT);
  pinMode(motor_counterclockwise, OUTPUT);
  pinMode(button, INPUT_PULLUP);
  pinMode(green_led, OUTPUT);
  digitalWrite(green_led,HIGH);
  digitalWrite(motor_clockwise,LOW);
  digitalWrite(motor_counterclockwise,LOW);
}

void loop() {
  current_button_state = digitalRead(button);

  if (current_button_state == HIGH && previous_button_state == LOW && state == idle && millis() - time > debounce) {
    state = opening;
    time = millis();
  }
  previous_button_state = current_button_state;
  
  if (state == opening) {
    current_timer = millis() - timer;
    if (timer == -1) {
      timer = millis();
      digitalWrite(motor_counterclockwise,HIGH);
    } else if (current_timer >= open_stop_time && current_timer < shower_time) {
      digitalWrite(motor_counterclockwise,LOW);
    } else if (current_timer >= shower_time && current_timer < close_stop_time) {
      digitalWrite(motor_clockwise,HIGH);
    } else if (current_timer >= close_stop_time) {
      digitalWrite(motor_clockwise,LOW);
      timer = -1;
      state = idle;
    }
  } else {
    timer = -1;
  }
  digitalWrite(green_led, !state);
}

Credits

Sam Leong
1 project • 3 followers
Allie Bacholl
1 project • 2 followers
Nick Spaid
1 project • 2 followers
Jared Weber
1 project • 1 follower

Comments