Skip to content

Commit 0075f7a

Browse files
authored
Merge pull request #16 from brentru/improve-example
Example - show packet is received using the LED
2 parents c22fc0d + 4dafc33 commit 0075f7a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

examples/rfm9x_simpletest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
# CS = digitalio.DigitalInOut(board.RFM9X_CS)
2020
# RESET = digitalio.DigitalInOut(board.RFM9X_RST)
2121

22+
# Define the onboard LED
23+
LED = digitalio.DigitalInOut(board.D13)
24+
LED.direction = digitalio.Direction.OUTPUT
25+
2226
# Initialize SPI bus.
2327
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
2428

@@ -44,15 +48,19 @@
4448
# This means you should only use this for low bandwidth scenarios, like sending
4549
# and receiving a single message at a time.
4650
print('Waiting for packets...')
51+
4752
while True:
4853
packet = rfm9x.receive()
4954
# Optionally change the receive timeout from its default of 0.5 seconds:
5055
#packet = rfm9x.receive(timeout=5.0)
5156
# If no packet was received during the timeout then None is returned.
5257
if packet is None:
58+
# Packet has not been received
59+
LED.value = False
5360
print('Received nothing! Listening again...')
5461
else:
5562
# Received a packet!
63+
LED.value = True
5664
# Print out the raw bytes of the packet:
5765
print('Received (raw bytes): {0}'.format(packet))
5866
# And decode to ASCII text and print it too. Note that you always

0 commit comments

Comments
 (0)