fixed a problem with undefined variables

This commit is contained in:
Simon Pirkelmann 2019-07-04 10:55:40 +02:00
parent 24cf87e9dd
commit cfa669e498

View File

@ -2,7 +2,7 @@ import machine
import sys
from machine import I2C, Pin
i2c = False
i2c = True
if i2c:
import d1motor
else:
@ -13,14 +13,13 @@ import usocket
import esp
class Robot:
def __init__(self):
def __init__(self, i2c=True):
if i2c:
print("setting up I2C ...")
#d1 = Pin(5)
#d2 = Pin(4)
#i2c = I2C(scl=d1, sda=d2)
#i2c_scan = i2c.scan()
i2c_scan = []
d1 = Pin(5)
d2 = Pin(4)
i2c = I2C(scl=d1, sda=d2)
i2c_scan = i2c.scan()
if len(i2c_scan) > 0:
i2c_addr = i2c_scan[0]
print("i2c scan = {}".format(i2c_addr))