0) Welcome to the forum!
1) As is common, we need more information.
1.1) Can you post some of your attempts, and what is wrong with each one?
1.1.1) Print them as PDF, or put the programs in one or more .ZIP files.
1.1.2) Attach the PDF or .ZIP file(s) to a post in this thread; use the [Go Advanced] option and look for the paper-clip icon to attach files.
1.2) What are the manufacturer, model number, software, programming language (ladder, FB, ST), etc. that you are using? That will be helpful so we can know what instructions are available.
2) I am not sure I understand the process, but here is how I interpret what you wrote:
2.1) There is one incoming lane of product to the process that you are trying to control
2.2) The product "flow" is comprises discrete events, i.e. it not continuous, i.e. it arrives one product at a time
2.2.1) There is a photo-eye discrete PLC input that is 1 when a product is detected by the photo-eye, and 0 otherwise
2.2.2) An edge of that PLC input (e.g. rising edge = transition from 0 to 1) triggers a counter to increment by 1
2.2.3) You have not said if a debounce on the photo-eye input may be necessary i.e. the photoeye may show multiple 0-to-1 and 1-to-0 transitions on a millisecond time scale at the arrival and/or departure of each product.
2.3) There are two outgoing lanes leaving the process
2.3.1) Let's call them [Lane 0] and [Lane 1]
2.4) There is a diverter that directs products coming from the single incoming lane into one or the other of the two outgoing lanes
2.4.1) There is a discrete PLC output that controls the diverter. Let's say when this output becomes 0 and the diverter has had time to move that the products will be diverted to [Lane 0], and when this output is 1 and the diverter has had time to move that the products will be diverted to [Lane 1].
2.4.2) The diverter takes time to move from directing product from one outgoing lane to the other outgoing lane
2.4.2.1) There is a "pause" arm, the intent of which is to hold the incoming product in the single incoming lane while the diverter is transitioning between output lanes.
2.4.2.1.1) There is a second discrete PLC output that controls the pause arm. Let's say this output will be 1 when the pause arm is extended and holding products back, and it will be 0 when the pause arm is retracted and products are free to move to the diverter.
2.4.2.1.2) The duration that the pause arm should be extended, while the diverter arm is transitioning, will be set by a timer.
2.4.3) The transition of the diverter arm from one lane to the other will be triggered by some number, 5-10, of product items detected by the photo-eye in the incoming lane.
Is that close to correct?
What about startup e.g. do you want the diverter to always start on one lane or the other. What about when power fails and is restored to the PLC?
P.S. I can't help but be reminded of this classic TV scene:
https://www.youtube.com/watch?v=NkQ58I53mjk