We propose a minimal model, based on active Brownian particles, for the dynamics of cells confined in a two-state micropattern, composed of two rectangular boxes connected by a bridge, and investigate the transition statistics. A transition between boxes occurs when the active particle crosses the center of the bridge, and the time between subsequent transitions is the dwell time. By assuming that the rotational diffusion time τ is a function of the position, the main features of the transition statistics observed experimentally are recovered. τ controls the transition from a ballistic regime at short time scales to a diffusive regime at long time scales, with an effective diffusion coefficient proportional to τ . For small values of τ , the dwell time is determined by the characteristic diffusion timescale which decays with τ . For large values of τ , the interaction with the walls dominates and the particle stays mostly at the corners of the boxes increasing the dwell time. We find that there is an optimal τ for which the dwell time is minimal and its value can be tuned by changing the geometry of the pattern.