AttributeError: 'Switch' object has no attribute 'value'

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
locoeng
Posts: 2
Joined: Tue Oct 30, 2018 9:07 pm

AttributeError: 'Switch' object has no attribute 'value'

Post by locoeng » Tue Jan 22, 2019 5:07 am

Hi all,

First post here, I keep getting this error any help would be appreciated. I'm following along with the tutorial for the pyb. TIA

PYB: sync filesystems
PYB: soft reboot
MicroPython v1.8.7 on 2017-01-08; PYBLITEv1.0 with STM32F411RE
Type "help()" for more information.
>>> sw = pyb.Switch()
>>> sw.value()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Switch' object has no attribute 'value'
>>> import pyb
>>> sw = pyb.Switch()
>>> sw.value()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Switch' object has no attribute 'value'
>>> from pyb import Switch
>>> sw = pyb.Switch()
>>> sw.value()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Switch' object has no attribute 'value'
>>>

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: AttributeError: 'Switch' object has no attribute 'value'

Post by dhylands » Tue Jan 22, 2019 10:51 pm

You're using an extremely old version of MicroPython.

The .value() attribute was added in 1.9.1 (you're using 1.8.7) and the latest version is 1.9.4

locoeng
Posts: 2
Joined: Tue Oct 30, 2018 9:07 pm

Re: AttributeError: 'Switch' object has no attribute 'value'

Post by locoeng » Wed Jan 23, 2019 6:56 am

Thanks!

I have since updated the board and have no issue.

Post Reply