[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

[pi8] Turning on a LED with Cylon.js

GPIO(General Purpose Input/Output ports) are the little pins sticking out of the circuit board and allow you to plug various devices into your Pi. With a little programming, you can then control them or detect what they are doing. See also GPIO pinout to explore different pin schemas and their uses in several protocols

Here we are trying to light a LED. In addition to your Raspberry Pi running Raspbian & S8 and Cylon loaded, what you will need is:

J8 Expansion Header

Check the GPIO pins layout on your pi device.

Blinking a LED with a command line script

  1. Copy and paste this code into a text file named ledblink.py
  2. Change mode for python file with:
    $ sudo chmod 755 ledblink.py
  3. Connect the LED to pin 3 on the Raspberry Pi GPIO.
    You can check out the connection diagram below to do that:
    Uploaded Image: ledPin3.jpg
  4. You should notice that the LED starts blinking after you execute the python script with
    $ sudo python ledblink.py
    The LED blinks because it receives a HIGH (5V) signal and a LOW (0V) signal from the Raspberry Pi GPIO at a delay of one second.

Blinking a LED with S8

  1. Start your S8 system (or the S8 system server executing
    node n8.snapshot.js)
    1. take note of the server address e.g. SystemServer running at http://192.168.1.???:8088
  2. connect from U8 tools image to S8 system running in your Raspberry Pi.
  3. install Cylon.js library and load Cylon framework to your system (using the remote/connected workspace)
  4. Turn on the light!