A South Tyneside warehouse worker kept awake at night by anxiety took cannabis to help him sleep – but then drove, a court heard.