Pages: [1]   Go Down
Author Topic: [SOLVED]Lightning detection arduino UNO  (Read 968 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley-eek-blue

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!!
« Last Edit: May 03, 2012, 11:51:03 am by Kaihos » Logged

Offline Offline
Edison Member
*
Karma: 9
Posts: 1016
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
Code:
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.
« Last Edit: May 03, 2012, 11:26:15 am by Krodal » Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 637
Posts: 34602
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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
Logged

Offline Offline
Edison Member
*
Karma: 9
Posts: 1016
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry but i solved my problems by myself  smiley-cool

Goodbyeeeeeeeeeee!! smiley-mr-green
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 637
Posts: 34602
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Pages: [1]   Go Up
Jump to: