Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*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:
- 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.
- */
- const int SENSOR_PIN = 2; // the pin connected to the sensor
- bool lightning; // whether a lightning strike was detected
- void setup() {
- Serial.begin(9600);
- pinMode(SENSOR_PIN, INPUT);
- }
- void loop() {
- // read the lightning detection data from the sensor
- lightning = digitalRead(SENSOR_PIN);
- // print whether a lightning strike was detected
- if (lightning) {
- Serial.println("Lightning strike detected!");
- } else {
- Serial.println("No lightning strike detected.");
- }
- // delay before reading from the sensor again
- delay(1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement