Hackster is hosting Hackster Holidays, Ep. 7: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 7 on Friday!
plouc68000
Published © GPL3+

Door opening counter with LED display and Battery Standby

Counts every opening of a door, displays the count on 4 digit LED and 10uA standby for 1 Year operation on AAA Batteries

BeginnerFull instructions provided2 hours93
Door opening counter with LED display and Battery Standby

Things used in this project

Story

Read more

Schematics

Component side

Code

Code for Pulse count TM1637

C/C++
for Pro Mini 5V, 3V or UNO , nano
// with sleep mode and count button wake-up
// Cut 1637 Power on low side via Pin LED_power !!!
// Tested 05/05/2024 JLG

#include <LowPower.h>
#include "SevenSegmentTM1637.h"
#include "SevenSegmentExtended.h"



// IO defines
#define Button 2 // Button on interrupt to wake-up from sleep
#define LED_power 7 // powered by pin (20mA max)

#define onboard_LED 13
#define Wreset 5
#define COUNT_0 6
#define PIN_CLK 3   // define CLK pin (any digital pin)
#define PIN_DIO 4  // define DIO pin (any digital pin)
SevenSegmentExtended    display1(PIN_CLK, PIN_DIO);

int counter=0;


void wakeUp()
{
  // Just a handler for the pin interrupt.
}




void setup() {
  digitalWrite(Wreset, HIGH);
  pinMode(Wreset, OUTPUT);
  
  digitalWrite(onboard_LED, LOW);
  pinMode(onboard_LED, OUTPUT);
  
  digitalWrite(LED_power, LOW);
  pinMode(LED_power, INPUT);

  
  pinMode(Button, INPUT_PULLUP);
  pinMode(COUNT_0, INPUT_PULLUP);

  Serial.begin(9600);


    counter=0;
    
}



void loop() {

  attachInterrupt(digitalPinToInterrupt(Button), wakeUp, FALLING); // new syntax
  LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);



  // after Button Press, continue from here
  detachInterrupt(digitalPinToInterrupt(Button));

  // Power ON and initialize
  
  pinMode(LED_power, OUTPUT);
  
  digitalWrite(onboard_LED, HIGH);
   
  
  // update LED

counter++;
if ( digitalRead(COUNT_0)== LOW ) counter = 0; // reset counter
display1.begin();         
display1.setBacklight(100);
display1.printNumber(counter);
 
 delay(2000); // showtime 2 sec
  
  
  // cut power
  
  pinMode(LED_power, INPUT);
  digitalWrite(onboard_LED, LOW);
  digitalWrite(Wreset, LOW);
}

Credits

plouc68000

plouc68000

10 projects • 121 followers

Comments