Currently I am working a project that has some unique objectives.
1) I am controlling a pump that must be fired only on the falling edge of an incoming rectified A/C square wave. This is the inline power. 2) I have to select 3 modes of speed for this pump to operate at. These speeds are determined by pulses per second that the pump operates at. Sometimes it fires every falling edge, while other modes fire every 3 falling edges or every 10 and so on. 3) The modes are selected by user input via push button.
The inline A/C square wave operates at 60Hz.
I started off with polling commands such as digitalRead, but now I've realized that the frequency is too fast for polling. I am attempting to write interrupt commands in order to detect the falling edge and fire the pump.
I'm having a difficult time rapping my head around the order of commands in order to accomplish this task.
So far this is the outline of the program I think I want
// Setup inline voltage variable - this can be treated like a button changing state int inlineVoltageInt = 0 //Interrupt Digital Pin 2
//setup constants for pump and push button const int buttonPin = 3; const int pumpPin = 5;
//volatiles setup some volatile variables for interrupt commands
void setup() - declare pinModes and interrupt commands
void loop() // detects push button // selects pump mode
void interrupt command() use interrupt to detect falling edge and firepump
Any help is appreciated.
Thanks Arduino Community!