Last active
February 1, 2021 11:44
-
-
Save raspberrytipsnl/d564f4f81e5b6d711b3e37d31df27aa3 to your computer and use it in GitHub Desktop.
Laser module python script (Raspberry Pi)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Control Lasermodule from Raspberry Pi | |
# https://raspberrytips.nl/laser-module-aansturen-via-gpio/ | |
import RPi.GPIO as GPIO | |
import time | |
LaserGPIO = 17 # --> PIN11/GPIO17 | |
def setup(): | |
GPIO.setmode(GPIO.BCM) | |
GPIO.setup(LaserGPIO, GPIO.OUT) | |
GPIO.output(LaserGPIO, GPIO.HIGH) | |
def loop(): | |
while True: | |
print 'Laser=on' | |
GPIO.output(LaserGPIO, GPIO.HIGH) # led on | |
time.sleep(1.0) | |
print 'Laser=off' | |
GPIO.output(LaserGPIO, GPIO.LOW) # led off | |
time.sleep(1.0) | |
def destroy(): | |
GPIO.output(LaserGPIO, GPIO.LOW) | |
GPIO.cleanup() | |
if __name__ == '__main__': | |
setup() | |
try: | |
loop() | |
except KeyboardInterrupt: | |
destroy() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Aansluitschema en overige informatie kun je terugvinden op:
https://raspberrytips.nl/laser-module-aansturen-via-gpio/