Photochemically Controlled Molecular Machines with Sequential Logic Operation