Final working code for RGB prototype