Created
April 6, 2012 14:48
-
-
Save alx/2320510 to your computer and use it in GitHub Desktop.
PyPong - Ledpgon with Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import serial | |
| import time | |
| class pypong: | |
| def __init__(self, port="/dev/ttyACM0", baudrate=38400): | |
| self.__s = serial.Serial(port=port, baudrate=baudrate) | |
| def send_text(self, data): | |
| if len(data) == 432: | |
| try: | |
| self.__s.write("Z%s"%data) | |
| except: | |
| print("failed write data") | |
| else: | |
| print("len of data not 433") | |
| def close(self): | |
| self.__s.close() | |
| p = pypong() | |
| while True: | |
| p.send_text("000000F0FF0F00F000F000FFFF0FF0F00FFFF0FF0F000FF000000000000000000000F0000F0000F000000000000000000F0000FF000F00000000000FFF0000000FFF000000000FF00000F0FFFF0FF0F00FFFF000000F00F0000000F0FF0000000F00000FF00FFFF00F0000FF0F000000000000000000FFF00FFF000FFF0F0F000000F0F0F00FFFF00FFFF0FFFF00000000000000000FFF0000FFF0F0F00000F00FF0F000000000F0000000F0000000000FF0F0FFFF00FFF00FF0F0F0000F0F000F0FF000000FFFF00000000000000000000000FFFF0FFFF0") | |
| try: | |
| time.sleep(1) | |
| except: | |
| break | |
| p.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment