Playing with laser is cool and controlling the laser with Linux is uber cool. I have been playing with 45 in 1 sensor kit. As part of it comes the laser module. Its a small laser light which is a equivalent to a keychain laser light with gpio controllable pinouts. I have already written on how to setup laser with Arduino. Now we will see how to get it working with Orange Pi Zero running armbian Linux.
For this project you need
Orange Pi Pinout is shown below.
Here we are going to use the GND pin and the GPIO PA12 on the top left for controlling the laser
git clone https://github.com/duxingkei33/orangepi_PC_gpio_pyH3 cd orangepi_PC_gpio_pyH3 python setup.py install
Now I used the standard blink led example from the repository
to run the blink laser example.
#!/usr/bin/env python """Basic blinking led example. The led on A20-OLinuXino-MICRO blinks with rate of 1Hz like "heartbeat". """ import os import sys if not os.getegid() == 0: sys.exit('Script must be run as root') from time import sleep from pyA20.gpio import gpio from pyA20.gpio import port __author__ = "Stefan Mavrodiev" __copyright__ = "Copyright 2014, Olimex LTD" __credits__ = ["Stefan Mavrodiev"] __license__ = "GPL" __version__ = "2.0" __maintainer__ = __author__ __email__ = "firstname.lastname@example.org" led = port.PA12 gpio.init() gpio.setcfg(led, gpio.OUTPUT) try: print ("Press CTRL+C to exit") while True: gpio.output(led, 1) sleep(0.1) gpio.output(led, 0) sleep(0.1) gpio.output(led, 1) sleep(0.1) gpio.output(led, 0) sleep(0.1) sleep(0.6) except KeyboardInterrupt: print ("Goodbye.")
If you are able to run the above code sucessfully then you will
be controlling laser with Linux 🙂