Well as the title says, this is my very first arduino project and also my first experience programming at all, so please bear with me.
What I tried to do with this little circuit is very simple and basic:
-Press a button and wait for an hour, if the button is still pressed, activate a Relay
-If the relay is on, read a digital sensor input. If both conditions are on, wait for 24 hrs.
-After the 24 hrs, turn the relay off.
-Wait for another 24 hrs and repeat the cycle again.
So, I compiled it and it didnt gave out any error messages, but that doesnt mean it will execute as I think it would. I plan on running it on monday, but could any of you guys give the code a quick check to see if it will actually do what I intend to do? I used Jeremy Blum´s “Exploring Arduino” book for my basic training.
const int RELAY=9; //Salida hacia el reelevador
const int BUTTON=2; //Boton de presencia de Fuselaje
const int SENSOR=3; //Sensores inductivos
boolean lastButton= LOW;
boolean currentButton= LOW;
boolean relayOn= false;
void setup ()
pinMode (RELAY, OUTPUT);
pinMode (BUTTON, INPUT);
pinMode (SENSOR, INPUT);
boolean debounce (boolean last) //Debounce the button thats going to be pressed
boolean current= digitalRead (BUTTON);
if (last != current)
current = digitalRead (BUTTON);
void loop ()
currentButton = debounce (lastButton);
if(lastButton= LOW && currentButton== HIGH) //You have pressed the button that activates the circuit
delay (3600000); //Wait for an hour
digitalWrite (RELAY, HIGH); //Turn the relay on
if(SENSOR== HIGH && RELAY== HIGH) //The relay is on and the sensors have become active
delay (86400000); //Wait 24 hours
digitalWrite (RELAY, LOW); //Deactivate relay
delay (86400000); //Wait additional 24 hours before scanning for conditions again