Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import smbus
- import time
- import os
- bus = smbus.SMBus(1)
- adr = 0x22
- def readButtons():
- try:
- res = bus.read_i2c_block_data( adr, 0xFF, 3 );
- a = res[0]
- b = res[1]
- c = res[2]
- return (a * 255 + b), c
- except:
- return 0,0
- a, c = readButtons()
- print bin(c),1
- a, c = readButtons()
- print bin(c),2
- b = 31
- print bin(c), ' binary value c'
- print bin(b), ' binary value b'
- while 1:
- a, c = readButtons()
- print bin(c), ' binary value c'
- print bin(b), ' binary value b'
- if ((c & 1) != (b & 1)):
- b = c
- print bin(c & 1), ' test1'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement