Giter Site home page Giter Site logo

rpio-led-demo's Introduction

This repo is a demo of controlling an LED with Raspberry Pi's GPIO, based on Jonathan Perkin's article "A node.js-powered 8-bit CPU".

Devices

Following devices are needed.

  • A Raspberry Pi
  • A BreadBoard
  • Some LEDs
  • Some jumper wire
  • Some 270 Ohm (Ω) resistors

Prerequisites

(1) A jumper wire going from pin 11 on the Raspberry Pi (GPIO 17) to a socket on the positive line of the breadboard.

(2) A jumper wire going from pin 6 on the Raspberry Pi (ground) to a socket on negative line of the breadboard.

(3) An LED vertically, with the anode (positive) above and the cathode (negative) below. To determine the correct orientation the bottom side is usually flat, and/or the anode is longer.

(4) A 270Ω resistor connecting the breadboard's negative line to the LED's cathode line. The resistor is required to reduce the voltage from 3.3V down to the 2.0V or so that the LED needs - without it the LED will likely burn brightly for a short time before blowing.

(5) Add the current user into GPIO group.

$ sudo adduser pi gpio

In the above line, pi is the default user of Raspberry Pi.

Install

Now, clone the repo and install the dependencies.

$ git clone https://github.com/ruanyf/rpio-led-demo.git
$ cd rpio-led-demo
$ npm install

Usage

Turn the LED on.

$ node led-on.js

Turn the LED off.

$ node led-off.js

Make the LED blinking.

$ node led-blink.js

Launch a server on port 8080.

$ node server.js

Open another terminal, and visit the port.

$ curl http://localhost:8080

When receiving a request, the server will send a signal to make the LED giving a blink.

rpio-led-demo's People

Contributors

ruanyf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.