Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from pathlib import Path
- # initial configuration of a gpio, or changing it between input and output:
- Path('/dev/gpio/P2_35/direction').write_text('in') # configure as input
- Path('/dev/gpio/P2_35/direction').write_text('low') # configure as output, initially low
- Path('/dev/gpio/P2_35/direction').write_text('high') # configure as output, initially high
- # if configured as input, can read value with:
- value = int( Path('/dev/gpio/P2_35/value').read_text() )
- # value is 0 (for low) or 1 (for high)
- # if configured as output, change value with:
- Path('/dev/gpio/P2_35/value').write_text('0') # set low
- Path('/dev/gpio/P2_35/value').write_text('1') # set high
Advertisement
Add Comment
Please, Sign In to add comment