Commit fefeef46 authored by Rafer Cooley's avatar Rafer Cooley
Browse files

init

parents
let id = 0
input.onButtonPressed(Button.A, () => {
if (id > 0) {
id = id - 1
radio.setGroup(id)
}
basic.showNumber(id)
})
input.onButtonPressed(Button.B, () => {
if (id < 9) {
id = id + 1
radio.setGroup(id)
}
basic.showNumber(id)
})
id = 0
radio.setGroup(id)
basic.showNumber(id)
basic.forever(() => {
radio.sendNumber(id)
basic.pause(150)
})
radio.setGroup(1)
basic.forever(() => {
radio.sendNumber(0)
basic.showLeds(`
. . # . .
. # # # .
# # . # #
. # # # .
. . # . .
`)
})
from microbit import *
import radio
radio.on()
radio.config(channel=1)
display.show(Image.DIAMOND_SMALL)
while True:
radio.send("0")
\ No newline at end of file
let id = 0
input.onButtonPressed(Button.A, () => {
if (id > 0) {
id = id - 1
radio.setGroup(id)
}
basic.showNumber(id)
})
input.onButtonPressed(Button.B, () => {
if (id < 255) {
id = id + 1
radio.setGroup(id)
}
basic.showNumber(id)
})
basic.showLeds(`
. . # . .
. # # # .
# # . # #
. # # # .
. . # . .
`)
id = 0
basic.forever(() => {
radio.sendNumber(0)
basic.pause(1250)
})
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
radio.onDataPacketReceived( ({ signal, receivedNumber }) => {
if (signal > -60) {
// 1 - Display an image for the highest signal strength
basic.pause(20)
basic.showIcon(IconNames.Yes)
} else if (signal > -65) {
// 2 - Display an image for the second highest signal strength
} else if (signal > -75) {
// 3 - Display an image for the medium signal strength
} else if (signal > -95) {
// 4 - Display an image for the second lowest signal strength
} else {
// 5 - Display an image for the lowest signal strength
}
})
radio.setGroup(1)
basic.showIcon(IconNames.Diamond)
\ No newline at end of file
from microbit import *
import radio
# 1 - Choose an image for the strongest signal
# 0 means the light is off
# 1-9 means the light is on [9 is the brightest setting for an LED]
strength_1 = Image("00000:"
"00000:"
"00000:"
"00000:"
"00000")
# 2 - Choose an image for the second strongest signal
strength_2 = Image("00000:"
"00000:"
"00000:"
"00000:"
"00000")
# 3 - Choose an image for the medium strength signal
strength_3 = Image("00000:"
"00000:"
"00000:"
"00000:"
"00000")
# 4 - Choose an image for the second weakest signal
strength_4 = Image("00000:"
"00000:"
"00000:"
"00000:"
"00000")
# 5 - Choose an image for the weakest signal
strength_5 = Image("00000:"
"00000:"
"00000:"
"00000:"
"00000")
display.show(Image.DIAMOND_SMALL)
radio.on()
radio.config(group=1)
while True:
details = radio.receive_full()
if details is not None:
x, rssi, y = details
if (rssi>-60):
# 1 - Example: Show the strength_1 (strongest) image
display.show(strength_1)
sleep(20)
display.show(Image.YES)
elif (rssi>-65):
# 2 - Show the strength_2 image
display.show(Image())
elif (rssi>-75):
# 3 - Show the strength_3 image
display.show(Image())
elif (rssi>-95):
# 4 - Show the strength_4 image
display.show(Image())
else:
# 5 - show the strength_5 image
display.show(Image())
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment