LIGHTNING COUNTER WITH 595 SEVEN SEGMENT DISPLAY

How much lightning strikes in the sky above your place of residence, it is important to know what the typical electrical area around you is, so you can decide what type of building is suitable to build, how high, how many lightning rods are needed.
This project is a simple way to find out how much lightning intensity is above you.

lightning conter led display

#include “Four7Seg74hc595.h”

esl::Four7Seg74hc595 display( 5,6,7 ); // SCLK, RCL, DIO pins, respectively

int reading;
int lm35Pin = 1;
char sbuf[5];
uint16_t count;
uint32_t ts1, ts2;

// this constant won’t change:
const int buttonPin = 2; // the pin that the pushbutton is attached to
const int ledPin = 13; // the pin that the LED is attached to

// Variables will change:
int buttonPushCounter = 0; // counter for the number of button presses
int buttonState = 0; // current state of the button
int lastButtonState = 0; // previous state of the button

void setup() {
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
for (uint8_t i=0; i < 100; i++) {
display.setDigits( “—-“, 4 );
display.update();
delay(10);
}
delay(1000);
count = 0;
sprintf( sbuf, “%04u”,count);
display.setDigits( sbuf, 4 );
display.update();
ts1 = ts2 = millis();
}

uint32_t ts;
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState != lastButtonState) {
if (buttonState == LOW) {
buttonPushCounter++;

} else {
}
// Delay a little bit to avoid bouncing
delay(1);
}
lastButtonState = buttonState;
//Serial.print(“number of lightning: “);
//Serial.println(buttonPushCounter);
ts = millis();
if ( ts – ts1 >= 10 ) {
sprintf( sbuf, “%04u”, buttonPushCounter );
ts1 += 10;
}
display.setDigits( sbuf, 4 );
display.update();
}