[SOLVED]Lightning detection arduino UNO

Hello guys!!

I'm new here but the arduino programming and the c++ generic coding is familiar for me.

I have a problem here on this code

#define pLed 2 //here is attached a resistor and a led on series
#define ceFul A0 //here comes in a signal from an whip antenna
void setup()
{
pinMode(ceFul, INPUT); //you know what this is .........
pinMode(pLed, OUTPUT);
digitalWrite(pLed, LOW);
}

void loop()
{
if(analogRead(ceFul)==HIGH) //if the signal is HIGH it should
{
digitalWrite(pLed,HIGH);
delay(10); //light up the led for 10 ms
digitalWrite(pLed,LOW);
delay(10);
}
}

It's fine and correct, but the led is lighting like the blink sketch in basics - and the fun part is that it lights up randomly :fearful:

Please, Help me !!!
Bye!!

[...............................................................]

Well, it happens that the analogic pin when used with other voltage generators, it makes a lot of high impedence signals, wich i detected later. So i changed few things :

  1. the if instruction uses a int variable and not the direct input signal;
  2. used a logic pin and not more analogic, after some trials works well;
  3. Tried and tried and now it works.
    Anyway, you can always give me a hand constructing a real antenna filter and signal receiver from the 590 kHz frequency. Sorry for bad english and, have a nice day!!

A led that is on for 10ms is almost not visible.
You could use a delay of 200ms for both delays.

Or just follow the input:

void loop()
{
  int i;
  
  i = analogRead(ceFul);
  if (i == HIGH)
  {
     digitalWrite(pLed, HIGH);
     delay(500);
  }
  else
  {
     digitalWrite(pLed, LOW);
  }
}

This code tries to detect a small pulse, that will keep the led on for 500 ms.
If the input is LOW most of the time, there is no delay in the loop, so the input is checked with a high frequency.

but the led is lighting like the blink sketch in basics

That is because the input is floating:-
http://www.thebox.myzen.co.uk/Tutorial/Inputs.html

To detect lighting you need a very large coil, and some protection on the analogue input, like catcher diodes:-
http://www.thebox.myzen.co.uk/Tutorial/Protection.html

I assumed that there was a protected input circuit.
But a resistor in series with the input can be 10k for the Arduino.

Sorry but i solved my problems by myself 8)

Goodbyeeeeeeeeeee!! :grin:

Sorry but i solved my problems by myself smiley-cool

Goodbyeeeeeeeeeee!!

Sorry not good enough. You asked for help, you got some, and now you have an obligation to post the solution to help others searching the threads in future.