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

Save data with analog read #119

Closed
ClementMISP2021 opened this issue Aug 22, 2022 · 0 comments
Closed

Save data with analog read #119

ClementMISP2021 opened this issue Aug 22, 2022 · 0 comments

Comments

@ClementMISP2021
Copy link

I am using a potentiometer to get a value between 0 and 1. I am able to print it in the console but the type of the data is 'NoneType'. Would it be possible to change this data type to a 'float' so that I can save it in a variable? Here is my code for now:

from pyfirmata import Arduino
import pyfirmata
import time
port = "COM3"
board = Arduino(port)
List = []
pin = board.get_pin('a:0:i')
it = pyfirmata.util.Iterator(board)
it.start()
print("Start reading")
for i in range(3):
    analog_value = pin.read()
    print(analog_value)
    List.append(analog_value)
    time.sleep(0.1)
    del List[0]
print(List)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant