Just cover the basics first for my own satisfaction.
Correct number of balls in the machine? 6 (5 plus 1 ceramic)
Correct number of balls in gumball machine and ball trough at startup? 3 for each
If these are correct then it will be a flaky opto (upper or middle) in the ball lock, a faulty lower switch in the ball lock or as Cavey said a faulty switch in the ball trough.
Got into switch edges test and fire a ball by hand into the ball lock and watch the matrix on the DMD to see if the optos/switches register (both of them, there is an upper and lower) and that there is no flickering.