Interesting Programs

There are many approaches to writing these programs, however, you will find that using functions and classes should make it easier to code, easier to understand, and easier to reuse the code.

Exercises

Thermometer: Imagine that the LED strip is connected to a thermometer.
  • Make a program that you can give a single value of temperature between 10 and 30°C and light up the appropriate number of leds. For example, if you give it 26°C it lights up 16 leds.
  • If you have not already, make a function that takes the temperature as an input and then lights up the correct number of lights.
  • Make a loop that randomly generates temperature values and then uses the function to light up the correct number of lights. Looping about 10 times, with a 2 second delay between iterations should be a good test.
Binary Timer/Clock
  • Make a function that converts base 10 numbers into binary and shows the binary representation on the led strip.
  • Make a countdown timer for 20 seconds, that counts down in binary.
  • Use your function to make a binary clock. Have three sections of the led strip, one each for hours, minutes, and seconds.