//Define LEDS pins
const int moonEclipsePin = 2;
const int sunEclipsePin = 3;
//Define potentionmeter pins
const int potentionmeterPin = A0;
void setup() {
// put your setup code here, to run once:
pinMode(moonEclipsePin, OUTPUT);
pinMode(sunEclipsePin, OUTPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
int potValue = analogRead(potentionmeterPin);
int moonDays = map(potValue, 0, 1023, 0, 30); // Map the potentionmeter value to days until moon Eclipse(assuming a 30 days)
int sunDays = map(potValue, 0, 1023, 0, 60); // Map the potentionmeter value to days until sun Eclipse(assuming a 60 days cycle)
//Determine if the moon eclipse is imminent
if (moonDays <= 5){
digitalWrite(moonEclipsePin, HIGH); // Turn on the moon Led
}else{
digitalWrite(moonEclipsePin,LOW); // Turn off moon eclipse Led
}
//Determine if the sun eclipse is imminent
if (sunDays <= 10){
digitalWrite(sunEclipsePin, HIGH); // Turn on the sun eckuose Led
}else{
digitalWrite(sunEclipsePin, LOW);
}
Serial.print ("Days until Moon Eclispe:");
Serial.println(moonDays);
Serial.print("Days until Sun Eclipse:");
Serial.println(sunDays);
delay(150);
}