Context
Turning house lights on when night falls and graphing the light variation over time.
Light level is displayed as a % and arbitrarily categorised as Dark, Dim, or Bright. The LED is switched on when Dark. The Gravity sensor has a detection range from 1-6000 Lux.
Examples of light levels: Very Bright Summer Day 100,000 Lux; Full Daylight 10,000 Lux; Overcast Summer Day 1,000 Lux; Very Dark Day 100 Lux; Twilight 10 Lux; Full Moon< 1 Lux
Accessories (Gravity)
Analog Ambient Light Sensor: DFR0026
Digital White LED Light Module: DFR0021-W
Directions
Construct a cardboard house with the light sensor mounted on the roof, and a LED in a window. The LED can be turned on and off (simulating day and night) by holding a hand between sensor and light source.
- Plug the chosen light sensor into plug P4
- Plug the LED into Plug 2
- Logging of light level starts as soon as app is switched on; and off when it is exited
- The sampling interval has a default of 2 secs in the initial Kappconfig.txt file. For longer sampling period, ie, every 10 seconds, edit the file in the flash memory with any text editor for a duration of 10 seconds.
- The Kooklog Excel file in the USB drive store can be uploaded to a PC for analysis
Algorithm
- Import initial conditions from the Kappconfig.txt file via the Kapputils.py file
- Create the analog and digital input and output,and turn off radio to conserve power
- Read the light sensor and categorise the value into Dark, Dim and Bright
- Commence data logging
- If Dark, switch the LED on.
- If Bright, switch the LED off
- If Dim, leave the LED in its current state
- On exit, switch the LED off and cease data logging