Cleaning Up Code

 

Really Reading, Really Understanding.

When you’ve finished that I’d like you to go through each line in your Arduino sketch and make sure you understand what each line of your code is doing. Really Understanding. Not just ‘sort of’… If you don’t really know then ask one of us and we will explain it.

When you really know what a line of code is doing add a comment describing what it is doing in your language that you will understand.

Do this now.

Cleaning up your Code.

Are there bits of code you don’t really need left in your sketch? Are there old comments that are no help anymore or are wrong? .. get rid of all of them.

Are there sections that would be better moved together;  all the IF statements? all the places we print text(display.println(); ), all the variables initialised (made) in one place? If they are not move them.

Are there sections that would be better moved out into methods/functions like we did with the draw elements?