lightning detector

Lightning Detector for Arduino

Lightning Detector for Arduino

Hardware required

Arduino
Breadboard
Jumper Wires

Components

2 – 10k Ohms Resistor
1 – 3.3M Ohms Resistor

Price of components = 20npr

lightning detector
lightning detector

Arduino code

#define FASTADC 1

#define FASTADC 1

// defines for setting and clearing register bits
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif

int data = 512;
int storage[512];

long batchStarted;
long batchEnded;
int reading;
int count;
int maximum;
int minimum;
bool toSend;

void setup() {
#if FASTADC
// set prescale to 16
sbi(ADCSRA,ADPS2) ;
cbi(ADCSRA,ADPS1) ;
cbi(ADCSRA,ADPS0) ;
#endif
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(A4,INPUT);
Serial.println(micros());

batchStarted=0;
batchEnded=0;
reading=0;
count=0;
maximum=0;
minimum=1023;
toSend=false;
}

void loop() {
// put your main code here, to run repeatedly:
reading = (analogRead(A4));
storage[count]=reading;
if ((!toSend)&&(count!=0)&&((reading>storage[count-1]+10)||(reading>>”);
Serial.println(batchStarted);

for (int i=0;i