Skip to content

added python generator for digital sensor #303

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

Open
wants to merge 1 commit into
base: python_upgrade
Choose a base branch
from

Conversation

imnot4real
Copy link

No description provided.

Copy link

github-actions bot commented May 1, 2025

Visit the preview URL for this PR (updated for commit 8c5c3d4):

https://electroblocks-test--pr303-imnot4real-patch-6-n84qoq07.web.app

(expires Thu, 08 May 2025 18:42:49 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: ee2601c0ccbf59939014e34f9926e60f83034b58

@phptuts
Copy link
Member

phptuts commented May 8, 2025

Because digital_read_pin_2 is not declared, it's probably not going to work. Can you take a look at this?

from pyfirmata import Arduino, util
board = Arduino('/dev/ttyACM0')  # Change to match your port
it = util.Iterator(board)
it.start()





while True:
  # The if statement checks a condition and executes the
  # following block of code if the condition is true.
  # Returns true if the sensor is sensing something.
  if digital_read_pin_2.read():

@phptuts
Copy link
Member

phptuts commented May 8, 2025

We probably want to keep using this in the import section if we can?

# Initialise the program settings and configurations
PORT = "YOUR_PORT_HERE"
board = pyfirmata.Arduino(PORT)

#Start the iterator thread to read inputs
it = pyfirmata.util.Iterator(board)
it.start()

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

Successfully merging this pull request may close these issues.

2 participants