Pseudo Code – Come up with a plan for coding.

Pseudo code is the name programmers give to instructions that are written in english, but cannot be understood by a computer.

Writing Pseudo code is actually a very important part of writing code well. And, it makes writing code much much easier.

Essentially, writing pseudo coding means working out the logic of your code *before* you write any real code. It means that you can separate working out the logic, from working out the semantics of the code.

Writing Pseudo Code

The advantage with pseudo code is that computers don’t have to understand it! In fact you just write it for yourself. You can write it any way you like. Here’s an example that works our a logic to make a button function as a toggle:

    - When the button is pressed, remember that it has been pressed
    - If the button hasn't been pressed, then increment x

Transfer pseudo code into comments

Now place your pseudo code into the relevant *real code* file. In Arduino (writing c++) it would look like this:

   // When the button is pressed, remember that it has been pressed

   // If the button hasn't been pressed, then increment x

Implement the comments!

Now follow your pseudo code and simply implement your comments!

// When the button is pressed, remember that it has been pressed
if ( digitalRead(2) == HIGH) {
  pressed = 1;
}
// If the button hasn't been pressed, then increment x
if (pressed == 0) {
 x++;
}