Lesson 3

Task 1: Recap


A variable is a virtual storage location paired with an associated name which is used to store values for subsequent use by the program.

Task 2: Measure angle


If.......statements allow the programmer to execute 2 sets of instructions when certain conditions are satisfied.

For example, if the input condition is True, the program will execute Instructions A and if condition is False, the program will execute Instructions B.

Task 3: Counter

  • Program the LED to display a number. The starting value is 0.
  • When Button A is pressed, the number will increase by 1. The maximum value is 9.
  • When Button B is pressed, the number will decrease by 1. The minimum value is 0.

Task 4: Countdown & BOOM!

  • When Button A or B is pressed, it works the same as in Task 3.
  • When Button A and B is pressed once, the LED will automatically countdown from 9 to 0, followed by the word, "BOOM!".
  • Hint :

Put the codes below in their correct order.