crwdns256162:0crwdne256162:0
crwdns256164:0crwdne256164:0
crwdns260052:0crwdne260052:0
crwdns274134:0crwdne274134:0
crwdns274136:0crwdne274136:0
crwdns256170:0crwdne256170:0
- crwdns260058:0crwdne260058:0 crwdns260060:0crwdne260060:0 crwdns260062:0crwdne260062:0
- crwdns260064:0crwdne260064:0
- crwdns260066:0crwdne260066:0
- crwdns260068:0crwdne260068:0
- crwdns260070:0crwdne260070:0 crwdns260072:0crwdne260072:0
crwdns260074:0crwdne260074:0
- crwdns260076:0crwdne260076:0 crwdns260078:0crwdne260078:0
- crwdns260080:0crwdne260080:0 crwdns260082:0crwdne260082:0 crwdns260084:0[1]crwdne260084:0
- crwdns260086:0crwdne260086:0 crwdns260088:0crwdne260088:0
- crwdns260090:0crwdne260090:0
crwdns260092:0crwdne260092:0
- crwdns260094:0crwdne260094:0
- crwdns260096:0crwdne260096:0
- crwdns260098:0crwdne260098:0
crwdns260100:0crwdne260100:0
crwdns260102:0crwdne260102:0
crwdns260104:0crwdne260104:0
1from microbit import *
2import radio
3radio.config(group=1)
4radio.on()
5light = Image(5,5) # create an empty image
6
7# function to map signal stength to LED brightness
8def map(value, fromMin, fromMax, toMin, toMax):
9 fromRange = fromMax - fromMin
10 toRange = toMax - toMin
11 valueScaled = float(value - fromMin) / float(fromRange)
12 return toMin + (valueScaled * toRange)
13
14while True:
15 message = radio.receive_full()
16 if message:
17 signal = message[1]
18 brightness = map(signal, -98, -44, 0, 9)
19 light.fill(round(brightness))
20 display.show(light)
21
crwdns260106:0crwdne260106:0
- crwdns260108:0crwdne260108:0
- crwdns260110:0crwdne260110:0
- crwdns260112:0crwdne260112:0 crwdns260114:0crwdne260114:0
- crwdns267250:0crwdne267250:0
- crwdns260118:0crwdne260118:0 crwdns260120:0crwdne260120:0
This content is published under a Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) licence.