Home > Uncategorized > Individual Assignment: Thermometer Exercise [Room Temperature]

Individual Assignment: Thermometer Exercise [Room Temperature]

For this assignment I have chosen to work with room temperature by using the CUI32 board, RGB LED-strips, TMP102 sensor and a small piezo speaker. The idea behind this concept is that the RGB LED-strips indicate if it is comfortable, too hot or too cold in a room by blinking a certain color depending on the temperature, which is measured by the TMP102 sensor. Additionally the piezo speaker plays a warning tone if it is too hot or too cold in a room, but if it is comfortable it mutes. The following items describe how the system works:

  • If room temperature is between 20° – 30 ° the RGB LED-strips turn green (comfortable) and no warning tone is played.
  • If room temperature is > 30° the RGB LED-strips turn red (too hot) and a warning tone is played.
  • If room temperature is < 20° the RGB LED-strips turn blue (too cold) and a warning tone is played.

Here is the BASIC code:

10 dim i, j
12 dim audio as pin rd1 for frequency output
20 dim cmd as byte, rsp[2] as byte
30 dim temp
40 dim leds[20] as byte
50 dim latch as pin rg9 for digital output open_drain
60 dim sync as pin rg6 for digital output open_drain
70 let latch = 0, sync = 0
80 while 1 do
81 if temp>30 then
82 let audio = temp*80
83 elseif temp<20 then
84 let audio = temp*40
85 else
86 let audio = 0
87 endif
101 print temp
121 let j = j+1
122 for i = 0 to leds#-1
123 if temp>30 then
124 let leds[i] = 0x80+0x4*(i==j%leds#)
125 elseif temp<=30&&temp>=20 then
126 let j = j+1
127 let leds[i] = 0x80+0x3
131 elseif temp<20 then
132 let j = j+1
134 let leds[i] = 0x80+0x10*(i==j%leds#)
135 endif
136 next
137 qspi leds
140 let latch = 1, latch = 0
150 let cmd = 0
160 i2c start 0x48
170 i2c write cmd
180 i2c read rsp
190 i2c stop
200 let temp = rsp[0]
240 endwhile
end

And finally here is the concept video:

Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a comment