From cfa669e498c4e4ba6bc45c6cf0040d2a251f426a Mon Sep 17 00:00:00 2001 From: spirkelmann Date: Thu, 4 Jul 2019 10:55:40 +0200 Subject: [PATCH] fixed a problem with undefined variables --- micropython_firmware/main.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/micropython_firmware/main.py b/micropython_firmware/main.py index ea79278..9b23838 100644 --- a/micropython_firmware/main.py +++ b/micropython_firmware/main.py @@ -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))