Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MCP3008 #465

Closed
Beamer12345 opened this issue Feb 1, 2023 · 4 comments
Closed

MCP3008 #465

Beamer12345 opened this issue Feb 1, 2023 · 4 comments

Comments

@Beamer12345
Copy link

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behaviour:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behaviour
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

System information:

  • OS: [e.g. Windows]
  • guizero version: [Type pip show guizero in a terminal/command prompt]

Additional context
Add any other context about the problem here.

@Beamer12345 Beamer12345 added the bug label Feb 1, 2023
@Beamer12345
Copy link
Author

trying to display value/read from the MCP3008 but get serval errors. below is the code i am using.

code i am trying to use.

import RPi.GPIO as GPIO # Defines RPi.GPIO just as GPIO
from gpiozero import MCP3008
from guizero import App, Slider
from threading import Thread

app = App()
adc = [MCP3008(i) for i in range(8)]
#adc = MCP3008(0)
sliders = [Slider(app, 0, 100) for pot in adc]

def update():
while True:
for slider, pot in zip(sliders, adc):
slider.set(pot.value * 100)

thread = Thread(target=update)
thread.start()

app.display()

@bsimmo
Copy link
Contributor

bsimmo commented Feb 1, 2023

Bug - It could just be your python code. Leave adding bug to the maintainers (been there myself, found the error of my ways)
You need to add the code markdown so we can see the white space.

But you shouldn't be using thread, you should be using the app repeat/update parts.
You shouldn't be using the while True loop.
You also need to provide the errors.

Here is an example of using sensor date with the SenseHAT I made some time back (no idea why I'm not on the list of people there, it was my pull request.). If using a RaspberryPi you can emulate the HAT to have a play (see line 7) https://github.com/lawsie/guizero/blob/master/examples/sensehat_read_data.py

also a slider example and link it to the potentiometer
https://github.com/lawsie/guizero/blob/master/examples/slider_textbox.py
and (GPIOZERO) https://gpiozero.readthedocs.io/en/stable/recipes.html#potentiometer

@martinohanlon
Copy link
Collaborator

There is some advice in the guizero docs about where you can get help - https://lawsie.github.io/guizero/gettinghelp/

I would suggest maybe the Raspberry Pi Forum. You may also want to include the errors you received.

I dont think this is a bug with guizero, nor do I have the ability to test, but will leave the issue open until I do the next release.

I did notice the code is using .set for Slider this isnt a supported method (it may of been in the past, but it would have been deprecated a long time ago.

slider.set(pot.value * 100)

To set the value of a Slider you should use the .value property e.g.

slider.value = pot.value * 100

@martinohanlon
Copy link
Collaborator

Closing due to lack of activity. Feel free to reopen if you have additional information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants