Skip to content

Instantly share code, notes, and snippets.

@raspberrytipsnl
Last active February 1, 2021 11:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raspberrytipsnl/d564f4f81e5b6d711b3e37d31df27aa3 to your computer and use it in GitHub Desktop.
Save raspberrytipsnl/d564f4f81e5b6d711b3e37d31df27aa3 to your computer and use it in GitHub Desktop.
Laser module python script (Raspberry Pi)
#!/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()
@raspberrytipsnl
Copy link
Author

raspberrytipsnl commented Feb 2, 2017

Aansluitschema en overige informatie kun je terugvinden op:

https://raspberrytips.nl/laser-module-aansturen-via-gpio/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment