Advertisement
Guest User

Untitled

a guest
Jun 29th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. from time import sleep
  2. from IoTPy.interfaces.gpio import GPIO
  3. from time import time
  4.  
  5. _UPER1 = 1
  6. _LPCexpresso = 2
  7.  
  8. ioBoardType = _LPCexpresso
  9.  
  10. LED_PIN_ID_1 = 'D6'
  11. from IoTPy.boards.metis import Metis as ioBoard
  12.  
  13. number = []
  14. message = []
  15. phrase = input()
  16. word = list(phrase)
  17. delta = 0.005
  18.  
  19. for num in word:
  20. number.append(ord(num))
  21.  
  22. for var in number:
  23. message.append("{0:{fill}8b}".format(var, fill=0))
  24.  
  25. bits = [int(b) for b in ''.join(message)]
  26. proto_sequence = bits + [0]
  27.  
  28. print(bits)
  29. print(message)
  30. with ioBoard() as board, board.digital(LED_PIN_ID_1) as ledPin1:
  31. ledPin1.setup(GPIO.OUTPUT)
  32. ledPin1.write(1)
  33. next_moment = (time() + 0.3)
  34. sleep(next_moment - time())
  35.  
  36. for bit in proto_sequence:
  37. ledPin1.write(bit)
  38. next_moment += delta
  39. sleep(next_moment - time())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement