You need to use these millis() timers to replace the delay(10000) in the output. Study the example in the ide "blink without delay" and look at Robin 2's Tutorial of Demonstration Code for Several Things at the Same Time. How could I edit my sketch to incorporate the delay (or its intended purpose- see sketch comments) and not disturb the interrupt's usefulness? You are not the first person to come to this forum with issues from running that flow meter code with interrupts disabled. Enable interrupts-count for a second-disable interrupts is pure rubbish. This is some of the worst code floating around the internet, and I doubt it will ever go away. Serial.print (" gal/hr\r\n") //Prints "gal/hour" and returns a new lineĭigitalWrite(outPin, HIGH) //This energizes the coil, closes the contacts, and passes control to the pressure switch while the high flow condition exists.ĭelay (10000) //maybe redundant but intended to allow the pump to run for 10 seconds beyond the demand signal and allowing tank to build reserve pressure. Serial.print (Calc, DEC) //Prints the number calculated above the loop() method runs over and over again, Serial.begin(9600) //This is the setup function where the serial port is initialized,ĪttachInterrupt(0, rpm, RISING) //and the interrupt is attached PinMode(outPin, OUTPUT) //initializes digital pin 4 as output PinMode(inputPin, INPUT) //initializes digital pin 2 as an inputĭigitalWrite(inputPin, HIGH) //enables internal pull up resistor The setup() method runs once, when the sketch starts NbTopsFan++ //This function measures the rising and falling edge of the hall effect sensors signal Void rpm () //This is the function that the interupt calls The coil is wired in series with the pressure switch. Int outPin = 4 //The pin connected to the pump contactor coil. Int inputPin = 2 //The pin location of the sensor Volatile int NbTopsFan //measuring the rising edges of the signal Code adapted by Charles Gantt from PC Fan RPM code written by Crenn http:/ reading liquid flow rate using Seeeduino and Water Flow Sensor from Code adapted from below referenced and modified by Christopher Norkus Results in energy savings while accepting small water losses. Disable a pressure switch controlled water pump to ignore small (ie: slow leak) flow rates. How could I edit my sketch to incorporate the delay (or its intended purpose- see sketch comments) and not disturb the interrupt's usefulness? Thank you. In my sketch it appears to me that the interrupt is closed prior to the delay function yet the delays are not taking place. I've read that the delay function will not run within an interrupt loop.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |