import smbus
import time
# for RPI version 1, use "bus = smbus.SMBus(0)"
bus = smbus.SMBus(1)

# This is the address we setup in the Arduino Program
address = 0x04

def writedegree(value):
    bus.write_byte(address,value)
    # bus.write_byte_data(address, 0, value)
    return -1

def readstate():
    number = bus.read_byte(address)
    # number = bus.read_byte_data(address, 1)
    return number

while True:
    var = input("Enter 1 - 180: ")
    if not var:
        continue
    
    print var;
    
    writedegree(var)
    print " I sent you ", var," degree."
    # sleep one second
    time.sleep(1)

    number = readstate()
    print "I received ", var, " degree."
    print