Likely I am missing something simple.
I have been playing around with a bit of code to exercise an old piece of hardware that I have here. Nothing too fancy, but I am getting an error that currently has me stumped.
My code 'test3.py' currently:
Code: Select all
#!/usr/bin/env micropython from machine import Pin, I2C import mcp23017 import machine import sys import utime i2c = I2C(scl=Pin(22), sda=Pin(21)) mcp = mcp23017.MCP23017(i2c, 0x20) BlueLed = Pin(16,Pin.OUT) BlueLed.value(1) repl_button = machine.Pin(0, machine.Pin.IN, machine.Pin.PULL_UP) x=0 # list interface mcp.output(0) mcp.output(0) mcp.output(0) mcp.output(0) mcp.output(0) mcp.output(0) mcp.output(0) mcp.output(0) mcp.input(pull=1) mcp.input(pull=1) mcp.input(pull=1) mcp.input(pull=1) mcp.input(pull=1) mcp.input(pull=1) mcp.input(pull=1) mcp.input(pull=1) while True: # If button 0 is pressed, drop to REPL if repl_button.value() == 0: mcp.porta.gpio = 0 #Line 44 follows next BlueLed.value(0) print("Dropping to REPL") sys.exit() # Turn LED on and then off mcp.porta.gpio = x #print(mcp.porta.gpio) utime.sleep_ms(500) BlueLed = not BlueLed x +=1
Looks to me like a variable scope issue yet, I am unaware of loops posing a such a dilemma, and I can't find anything documenting variable scope specs for within while loops.MicroPython v1.12-87-g96716b46e on 2020-01-26; ESP32 module with ESP32
Type "help()" for more information.
>>> import test3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "test3.py", line 44, in <module>
AttributeError: 'bool' object has no attribute 'value'
Yes, I know my code is all a bit rough around the edges, but it was never intended to be ready for prime time. This is really just an ongoing experiment and its really just this error I am seeking an assist with, thanks.
Your thoughts would be appreciated.