KC Coding Camp, 2022

Welcome to Camp, Day 4!

Our goal today will be to make a program that will utilize the customize the temperature sensor on board KittenBot to make a "Radiation Exposure Monitor". Coding the project is just one step in the process. As you do this you will have to think about the following:

  • Temperature conversion formulas
  • Measurement units
  • Ambient and direct temperature
  • Threshold and trigger values
  • User communication

First we will code for temperature and light by reading the sensors. Enter the following code in the visual editor:

What we have here is temperature reading on the top and a light reading at the bottom. Your readings may be a little bit off. Do you know why?

Let's make two changes.

  1. Convert Celsius to Farenheit temperature.
  2. Make the program update the sensor values continuously.

The formula for temperature conversion is:

The temperature T in degrees Fahrenheit (°F) is equal to the temperature T in degrees Celsius (°C) times 9/5 plus 32:

T(°F) = T(°C) × 9/5 + 32


T(°F) = T(°C) × 1.8 + 32

Convert 20 degrees Celsius to degrees Fahrenheit:

T(°F) = 20°C × 9/5 + 32 = 68 °F

In order to convert the temperature, you'll have to use the operators functions.

Once you have the formula entered in correctly, your temperature should show a more realistic number. It may be a bit challenging to get the formula built correctly but keep practicing.

After you have put the sensor readings in a loop, look for an operator function that will get rid of the decimals in the temperature. Which one did you pick?

Next, use your phone's flashlight to find out where the light sensor is and how the intensity of the light changes the value. Move the light around and observe its effect on the sensor.

Hold the KittenBot in your hand for a while and watch the temperature sensor change. Blow on KittenBot and watch what happens to the temperature in the breeze. Does it go down?

Now that we know that the sensor values work properly, we will change our program.

Make the following changes using your coding skills:

  • Flood fill the screen a solid red color based on a temperature above 90 degrees.
  • Flood fill the screen a different solid color based on a temperature above 98 degrees.
  • Flash the text "RADIATION EXPOSURE!" on the screen in Bold White when the KittenBot has been blasted by a large amount of light.

Here is the basic decision block you will need to create in order to change the screen. Notice we use x, a variable, which holds the temperature calculation so you only have to do it once.

In order to do this you will need to pay attention to the values of the light meter when you are holding your phone flashlight up to it. This will help you determine the amount of light that should be present in full sun.

We will make other modifications and test them.