// Define the analog input pin for the pager signal
#define Pager_IN A0
// Define the output pins for the RGB LED strip
#define RED_OUT 7
#define BLUE_OUT 6
#define GREEN_OUT 5
// Time to wait before activating the LED strip after pager activation (in milliseconds)
#define Activate_wait 120000
// Time to keep the LED strip in white color before returning to normal (in milliseconds)
#define Light_wait 120000
// Voltage threshold to detect pager activation (approximately 1.5V [1024 = 5V])
#define Pager_activation 204
// Setup function, runs once when the Arduino starts
void setup() {
// Set the RGB LED strip pins as outputs
pinMode(RED_OUT, OUTPUT);
pinMode(BLUE_OUT, OUTPUT);
pinMode(GREEN_OUT, OUTPUT);
// Set the pager input pin as an input
pinMode(Pager_IN, INPUT);
// Turn off all the LEDs in the RGB strip (HIGH means OFF in this setup)
digitalWrite(RED_OUT, HIGH);
digitalWrite(BLUE_OUT, HIGH);
digitalWrite(GREEN_OUT, HIGH);
// Start communication with the serial monitor at 9600 baud rate for debugging
Serial.begin(9600);
}
// Loop function, runs repeatedly after setup()
void loop() {
// Read the voltage value from the pager input pin
int PagerV = analogRead(Pager_IN);
// Print the voltage value read from the pager
Serial.print("Voltage from pager: ");
Serial.print(PagerV);
Serial.println("mV");
// Check if the pager voltage is above the activation threshold
if (PagerV >= Pager_activation) {
Serial.println("Pager activation detected.");
// Wait for the specified time before activating the LED strip
Serial.print("Waiting for ");
Serial.print(Activate_wait);
Serial.println("ms");
delay(Activate_wait);
// Change the LED strip color to RED
Serial.println("Changing Strip color to RED");
digitalWrite(RED_OUT, HIGH);
digitalWrite(BLUE_OUT, LOW);
digitalWrite(GREEN_OUT, LOW);
// Wait for the specified time while keeping the RED color
Serial.print("Waiting for ");
Serial.print(Light_wait);
Serial.println("ms");
delay(Light_wait);
// Change the LED strip color back to WHITE (all LEDs OFF)
Serial.println("Changing Strip color to WHITE");
digitalWrite(RED_OUT, HIGH);
digitalWrite(BLUE_OUT, HIGH);
digitalWrite(GREEN_OUT, HIGH);
}
// A small delay to avoid excessive loop iterations
delay(50);
}