-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMicroBit_LightSensorTransmit.py
More file actions
31 lines (25 loc) · 1009 Bytes
/
MicroBit_LightSensorTransmit.py
File metadata and controls
31 lines (25 loc) · 1009 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# This script will use the Microbit LEDs as a light sensor and transmit an alert (V1, Firmware 0249, Sept 2021)
# IDE (Integrated Development Environment)
# https://codewith.mu
# Bill of Materials
# Microbit v2 Go Kit
# https://www.adafruit.com/product/4834
# Source code
# https://microbit.org/projects/make-it-code-it/light-alarm/?editor=python
# Engineering background
# https://lancaster-university.github.io/microbit-docs/extras/light-sensing/
# https://core-electronics.com.au/tutorials/micropython-workshop-for-microbit.html
# https://microbit-micropython.readthedocs.io/en/v1.0.1/tutorials/buttons.html
# https://microbit-micropython.readthedocs.io/en/v1.0.1/tutorials/radio.html
from microbit import *
import radio
radio.config(group=5)
radio.on()
while True:
if button_a.was_pressed():
display.scroll(display.read_light_level())
if display.read_light_level() > 50:
radio.send('lights on')
else:
radio.send('lights off')
sleep(10000)