1
0

asynchronous_gpio_transmit.py 695 B

123456789101112131415161718192021222324252627
  1. import logging
  2. import time
  3. from RPi import GPIO
  4. import cc1101
  5. logging.basicConfig(level=logging.INFO)
  6. _GDO0_PIN = 18 # GPIO24
  7. GPIO.setmode(GPIO.BOARD)
  8. GPIO.setup(_GDO0_PIN, GPIO.OUT, initial=GPIO.LOW)
  9. with cc1101.CC1101() as transceiver:
  10. transceiver.set_base_frequency_hertz(433.92e6)
  11. transceiver.set_symbol_rate_baud(600)
  12. print(transceiver)
  13. print("starting transmission")
  14. with transceiver.asynchronous_transmission():
  15. while True:
  16. print(1, end="", flush=True)
  17. GPIO.output(_GDO0_PIN, GPIO.HIGH)
  18. time.sleep(1.0)
  19. print(0, end="", flush=True)
  20. GPIO.output(_GDO0_PIN, GPIO.LOW)
  21. time.sleep(1.0)