Advertisement
silver2row

learning from IRC #beagle

Mar 25th, 2022
1,161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. from pathlib import Path
  2. from time import sleep
  3.  
  4. class Gpio:
  5.     def __init__( self, name ):
  6.         self.name = name
  7.         self._value_path = Path( '/dev/gpio', name, 'value' )
  8.  
  9.     def get( self ):
  10.         return int( self._value_path.read_text() )
  11.  
  12.     def set( self, value ):
  13.         self._value_path.write_text( str( value ) )
  14.  
  15. relay1 = Gpio( 'relay-jp1' )
  16.  
  17. relay1.set( 1 )
  18. sleep( 1 )
  19. relay1.set( 0 )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement