![]() ![]() const int LED = 13 // Define the pin where your solenoid valve is connectedĬonst int buttonAPin = 10 // Define the pin for Push Button Aīool valveOpen = false // Track if the valve is currently openīool buttonAPressed = false // Track if Button A is pressed But I can't seem to stop the operation when it's more than 3 minutes. I was able to run this code where if button is push LED lights up for 6 seconds then off for 1 minute. Thanks for the input about millis, I tried to search about it and implement it on my code. Also, another button (BUTTON_B) to stop the operation if BUTTON_B is pushed.Īnyone who can direct me to implement this, would be of great help. It is still not in the code but I want this timer to only start when a button (BUTTON_A) is pushed. (But I know that my code for now turns LED ON for 6 secs, off for 6 secs) I have this code above, I have use timer interrupt to turn ON the LED for 6 seconds, but I want it to turn off for 15 minutes and then on again for 6 secs and off for 15 min., this cycle should last for 2 hours. LED_STATE = !LED_STATE //Invert LED stateĭigitalWrite(13,LED_STATE) //Write new state to the LED on pin D5 TCNT1 = 0 //First, set the timer back to 0 so it resets for next interrupt With the settings above, this IRS will trigger each 1s. put your main code here, to run repeatedly: OCR1A = 62500 //Finally we set compare register A to this value TIMSK1 |= B00000010 //Set OCIE1A to 1 so we enable compare match A We enable compare match mode on register A*/ We set the prescalar to the desired value by changing the CS10 CS12 and CS12 bits. First we reset the control register to amke sure we start with everything disabled.*/ PinMode(13, OUTPUT) //Set the pin to be OUTPUTĬli() //stop interrupts for till we make the settings ![]() * code with timer interrupt that will create an interruption eachĬount up to = 1000ms / 16us = 62500 (so this is the value the OCR register should have)*/
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |