Exploring how to program would be more rewarding if we knew a few fundamental coding concepts. But before we learn basic coding concepts, we need to know why do we need to make a program in the first place.
We make programs because we like to create, design and make things. Every computer program ever built was designed to solve something or serve a purpose. A program, which can be called a code or sometimes a script, tells a computer what to do. A program is basically just a set or list of instructions that is inputted to a computer to accomplish a certain task or solve a problem. These instructions typically have an order on which instruction or set is to be first executed and is called an algorithm.
Whatever you build with code should serve a purpose or fill a need. To help us design and make things, we will use a process called designed thinking – a specific framework for identifying problems, designing solutions, testing and refining.
The design thinking process includes five steps:
1. Empathize – learn and try to understand the problem you are trying to solve
2. Define – analyze and identify the problems or needs
3. Ideate – brainstorm several possible creative solutions
4. Prototype – construct rough drafts or sketches of your ideas
5. Test – test your prototype solutions, and refine until you come up with the final version
To illustrate and give examples of each stage, let’s try to design and simulate a street traffic light signal and use the design thinking process. First stage is to emphatize what we are trying to make, that is to simulate a traffic light signal using our micro:bit. Obviously, we can only use low voltage and that means LED lights only for our simulation and use our micro:bit to control the timing of the lights. We are trying to identify the things that are needed to accomplish our goal and this is called the define stage. We also need some wires, resistor and breadboard. The next stage is ideate and figure out how we can turn the LED lights on and off with a specific timing to simulate a traffic light using block programming. The fourth stage is to make a prototype and then build and test and refine our prototype which is the last stage of our process.
To start designing our program, it’s easier to write them down on a piece of paper and make a rough draft of our program. It will contain a step-by-step process on how our program will work. These skeletal instruction is what we call a pseudocode. It may just contain sentences describing the flow of the program or even contain actual code.
Our traffic light signal program might look like this:
1. Start with red signal light for 6 seconds.
2. Yellow signal lights up for 3 seconds.
3. Green signal lights up for 8 seconds.
4. Yellow signal lights up for 3 seconds.
5. Repeat step 1.