Giter Club home page Giter Club logo

pypicoboard's Introduction

pypicoboard

Python library for using the Scratch PicoBoard. Scratch has built in support for the PicoBoard. More information about the PicoBoard may be found here:

https://wiki.scratch.mit.edu/wiki/PicoBoard

Project page:

https://github.com/drewarnett/pypicoboard

To install:

pip install https://github.com/drewarnett/pypicoboard/archive/master.zip

Or, just grab the picoboard.py file.

Note: this library is Python2 and Python3 compatible.

Prerequisites:

  • pyserial

Example use:

>>> from picoboard import PicoBoard
>>> pb = PicoBoard('/dev/ttyUSB0')    # or 'COM1' or '/dev/ttyS0', etc.
>>> readings = pb.read()
>>> print(readings["button"])

The dictionary returned by read():

key (channel name) - value
A - resistance sensor A
B - resistance sensor B
C - resistance sensor C
D - resistance sensor D
button - button sensor
light - light sensor
slider - slider sensor
sound - sound sensor

pypicoboard's People

Contributors

drewarnett avatar

Stargazers

James avatar kecy avatar Özhan Fenerci avatar  avatar

Watchers

James Cloos avatar  avatar

pypicoboard's Issues

AttributeError: module 'serial' has no attribute 'Serial'

Traceback (most recent call last):
File "e:/Desktop/cv/main.py", line 2, in
pb = PicoBoard('COM1') # or 'COM1' or '/dev/ttyS0', etc.
File "C:\Users\oskil\AppData\Local\Programs\Python\Python38-32\lib\site-packages\picoboard.py", line 66, in init
self._interface = serial.Serial(serial_port, 38400, timeout=0.1)
AttributeError: module 'serial' has no attribute 'Serial

My Modules:
aiohttp 3.6.2
APScheduler 3.6.3
async-timeout 3.0.1
attrs 19.3.0
autoit 0.1
certifi 2020.6.20
chardet 3.0.4
click 7.1.2
comtypes 1.1.7
cycler 0.10.0
discord.py 1.3.4
dnspython 1.15.0
dnspython3 1.15.0
Flask 1.1.2
future 0.18.2
idna 2.10
iso8601 0.1.12
itsdangerous 1.1.0
Jinja2 2.11.2
kiwisolver 1.2.0
mariadb 1.0.0
MarkupSafe 1.1.1
matplotlib 3.3.0
mcstatus 3.1.1
mouse 0.7.1
MouseInfo 0.1.3
multidict 4.7.6
mysql-connector-python 8.0.21
numpy 1.19.0
opencv-python 4.3.0.36
ovr 1.16.1
Pillow 7.2.0
pip 20.1.1
praw 7.1.0
prawcore 1.5.0
protobuf 3.12.2
PyAutoGUI 0.9.50
PyDirectInput 1.0.2
PyGetWindow 0.0.8
PyMsgBox 1.0.8
pyparsing 2.4.7
pyperclip 1.8.0
pypicoboard 0.0.0
pypresence 4.0.0
PyRect 0.1.4
PyScreeze 0.1.26
python-dateutil 2.8.1
python-ovrsdk 0.3.2.2
PyTweening 1.0.3
pytz 2020.1
pywin32 228
pywinauto 0.6.8
PyYAML 5.3.1
requests 2.24.0
serial 0.0.97
setuptools 47.1.0
six 1.15.0
Snookey2 3.2.1
typing-extensions 3.7.4.2
tzlocal 2.1
update-checker 0.18.0
urllib3 1.25.9
websocket-client 0.57.0
websockets 8.1
Werkzeug 1.0.1
winput 1.2.2
yarl 1.5.0

AssertionError when getting values in quick succession

I'm sure this is an issue with my code, but I'm out of ideas. Here's what I'm using:

from picoboard import PicoBoard
pb = PicoBoard('/dev/ttyUSB1')    # or 'COM1' or '/dev/ttyS0', etc.

while True:
            readings = pb.read()
            print(readings["slider"])

I get this error. Sometimes it is immediate after the loop begins, other times, the loop can iterate over 1000 times.

Traceback (most recent call last):
  File "test2.py", line 7, in <module>
    readings = pb.read()
  File "/home/pi/pypicoboard/picoboard.py", line 101, in read
    channel, value = readchannel()
  File "/home/pi/pypicoboard/picoboard.py", line 87, in readchannel
    assert (upper_byte >> 7) & 1 == 1
AssertionError

This still occurs when waiting for 0.5 seconds before reading again, in case I was pushing too fast. This also occurs with all inputs. It's seemingly random. It doesn't happen after a set amount of iterations.

Any suggestions would be greatly appreciated!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.