i2c_console.py 456 B

123456789101112131415161718192021222324252627
  1. #! /usr/bin/python3
  2. import smbus
  3. import time
  4. bus = smbus.SMBus(1)
  5. # Match the arduino
  6. SLAVE_ADDRESS = 0x04
  7. #def writeNumber(value):
  8. # bus.write_byte(SLAVE_ADDRESS, value)
  9. # return -1
  10. #
  11. #def readNumber():
  12. # number = bus.read_byte(SLAVE_ADDRESS)
  13. # return number
  14. while True:
  15. var = input("Enter asdwrf :")
  16. if not var:
  17. continue
  18. bus.write_byte(SLAVE_ADDRESS, ord(var[0]))
  19. print("Sent '{}' to pi.".format(ord(var[0])))