Skip to content

활동

Energy light timer

고급 | MakeCode, Python | LED, 버튼, 빛 센서 | 13 날씨, 변수, 불 논리, 센서, 입력/출력

1단계: 만들어 보세요.

프로젝트 소개

Time how long your lights are left on to track your energy use. You could also use this project to track hours of sunshine in a weather station project.

이 프로젝트는 전세계 지속가능발전 문제들에 대한 해결 방법 중 하나로서, 컴퓨터과학기술을 탐색하고 활용해서 새로운 물건들을 만들어 내는 문제해결 과정을 경험할 수 있도록 만들어진 프로젝트들 중 하나 입니다.

학습 내용

  • how to use sensors and code to monitor real world events
  • place a data-logger to record reliable data
  • collect and collate data over time to spot patterns in energy use
  • interpret and analyse data in order to effect changes in behaviour
  • how variables can be changed by a user to configure a system prior to use

사용방법

  • First use the Energy light meter project to find out the readings when your lights are on and off. Make sure you do this in the same place and lighting conditions that you will place your monitoring micro:bit, and ensure daylight doesn't trigger a false reading that your lights are on.
  • Put your light reading into the code where the LIGHT variable is set. We have given you the number 100 but you will probably need to change this before flashing the code on to your micro:bit.
  • Attach a battery pack and place your micro:bit under the light you want to monitor. You should see a dot on the display when the light is off, and the display lights up when your light is on. If this doesn't work, consider using the Light meter project again to find the light level when the light is on, or move the micro:bit.
  • The micro:bit will keep timing and when you press button B it will show how long the light has been switched on in minutes.

설명

  • The program uses a Boolean variable called timing to control the program. Boolean variables can only have two values: true or false.
  • If the light sensor reading is above the level you set, it starts the timer and lights up the LED display. If it falls below this level, it stops the timer and shows a dot on the display.
  • This project uses hysteresis to make sure the timer doesn't switch on and off too often when the light level is changing slightly around the threshold for triggering the timer. It creates a larger band around the threshold which has to be crossed before the timer is turned on or off.
  • Hysteresis is a common feature in control systems that use sensors, for example in heating systems that have a thermostat. If you set your thermostat to a certain temperature, you don't want the heating repeatedly switching on and off very quickly when the temperature hovers around the number you have set. Hysteresis prevents this happening.

준비물

  • micro:bit
  • MakeCode 또는 Python 편집기
  • battery pack (recommended)

2단계: 프로그래밍 해보세요.

3단계: 더 좋게 만들어 보세요.

  • Change the patterns shown on the LED display to make the batteries last longer, or dim the display.
  • Use the time recorded to work out how much electricity you have used and what it may cost. Details are in our Energy cost calculator project
  • Use the same code to measure hours of sunlight. Use the Light meter project to calculate the light value when sun is shining on the micro:bit and when it's cloudy. You may need to make a container for your micro:bit with a translucent lid to diffuse the light and protect the micro:bit from rain, for example an old plastic food container.