Hello everyone, I guess this is my first post. Well, I'm currently using multiple 328s in my project. The job the MCU has to do is - 1. Take one pulse from a sensor 2. Take several pulses from a rotary encoder 3. Fire an output when the encoder hits a specified number of pulses.
For Example: When an object passes under the sensor it triggers an interrupt to start counting encoder pulses. When the encoder pulses have reached a certain number 'x', say it fires an LED.
My problem here is, this can be done with a simple program when it is just one object getting sensed. My requirement is multiple objects go under the sensor and when the encoder reaches 'x' pulses it fires the LED every-time.
So when the object is sensed, the encoder starts from zero, then heads up to 'x' and then the LED fires. Now, what if the first object is sensed, then the second and the third and so on, how can I make the encoder pulses start from zero every-time it senses a new object, before firing the LED for the previous object ? or what I mean is , I'm only able to finish a 'SENSE -> COUNT -> BLINK' for one object, I need to 'SENSE -> COUNT -> BLINK' for the next object, even though the 'SENSE -> COUNT -> BLINK' cycle for the previous object hasn't completed yet.
Sorry, I have no code at the moment, since I don't have a proper algorithm to start with.
Please help !