Leonardo's scientific journals were mostly written in a backward script which requires holding it up to a mirror to read. Whether he wrote in front of a mirror, was some sort of amazing dislexic, or more likely invented a machine to perform this encoding is unknown, but that he wrote in code is a well known historical fact.
His reasons for doing this might just be a secretive personality, but more likely stem from the times in which he lived. The Catholic Church at the time had a tendency to accuse people as heretics, and sometimes burn them at the stake for thinking original thoughts. Leonardo's anatomical studies, optical, and even aviation experiments could very easily have been branded as sorcery or witchcraft.
So the real Da Vinci Code is the one Leonardo invented to keep his journals private, and it is perhaps a far more interesting and solvable mystery than the one that has so thoroughly captured the public conciousness in recent years. As simple of a code as it is, it kept his writings secret for several decades after his death until someone finally solved the puzzle.