Lesson 3

Variables

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

If........statements

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 1

  • 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 2

  • When Button A or B is pressed, it works the same as in Task 1.
  • 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.