Advertisement
microrobotics

AS935 Lightning Detector Module

Mar 30th, 2023
889
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*The AS935 Lightning Detector Module is a digital sensor that detects the presence of lightning within a certain radius. Here's an example code in Arduino that reads the lightning detection data from the sensor:
  2.  
  3. Note: This code assumes that the AS935 Lightning Detector Module is connected to pin 2 of the Arduino board. If you're using a different pin, you'll need to modify the SENSOR_PIN definition accordingly. Also, the sensor is designed to detect lightning within a certain radius, so it may not detect all lightning strikes in the area.
  4. */
  5.  
  6. const int SENSOR_PIN = 2;  // the pin connected to the sensor
  7. bool lightning;  // whether a lightning strike was detected
  8.  
  9. void setup() {
  10.   Serial.begin(9600);
  11.  
  12.   pinMode(SENSOR_PIN, INPUT);
  13. }
  14.  
  15. void loop() {
  16.   // read the lightning detection data from the sensor
  17.   lightning = digitalRead(SENSOR_PIN);
  18.  
  19.   // print whether a lightning strike was detected
  20.   if (lightning) {
  21.     Serial.println("Lightning strike detected!");
  22.   } else {
  23.     Serial.println("No lightning strike detected.");
  24.   }
  25.  
  26.   // delay before reading from the sensor again
  27.   delay(1000);
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement