# pi-hw-pwm

> fast gpio control, including hardware pwm

Latest version **0.0.1** (published 2019-07-16) · ISC license · 0 weekly downloads

## Install

```sh
npm install pi-hw-pwm
pnpm add pi-hw-pwm
yarn add pi-hw-pwm
bun add pi-hw-pwm
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2019-07-16 |
| First published | 2019-07-16 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 10.2 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | shinobit |
| Maintainers | shinobit |
| Keywords | pigpio, servo, pwm, hardware pwm, raspberry, pi, raspberry pi, raspberrypi, dma, gpio |

## Links

- npm: https://www.npmjs.com/package/pi-hw-pwm
- Repository: https://github.com/nrbrt/pi-fast-gpio
- Homepage: https://github.com/nrbrt/pi-fast-gpio#readme
- Issues: https://github.com/nrbrt/pi-fast-gpio/issues
- npm.io page: https://npm.io/package/pi-hw-pwm

## Dependencies (2)

- [net](https://npm.io/package/net.md) ^1.0.2
- [put](https://npm.io/package/put.md) 0.0.6

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.0.1 (latest) — 2019-07-16

## README

pi-fast-gpio
============

Super fast GPIO access on the Raspberry Pi using the 
[pigpio](http://abyz.co.uk/rpi/pigpio/index.html) daemon (for pwm, servo
control, etc)

The pigpio library uses direct memory access (DMA) to allow you to sample
the GPIOs up to 1,000,000 times per second. It also makes it fast enough to
give you PWM and servo control on all GPIOs simultaneously. The servo
waveforms are accurate to a few microseconds.

This code is based off of the [python library](http://abyz.co.uk/rpi/pigpio/python.html)
included with the pigpio download.

Installation
------------

For now you'll just have to clone this repo

Usage
-----

Start the pigpio daemon:

    $ sudo pigpiod

In your program:

 1. require(...) the pi-fast-gpio library
 2. Create a new instance of the PiFastGpio class
 3. Call connect(...) to connect to the pigpiod daemon
 4. When connected, do what you please with the GPIOs on your Raspberry Pi
 5. Call close() when you're done and about to exit your program.

Examples
--------

There are two examples included, one that drives two servos, and one that uses
PWM to change the brightness of two LEDs

Before running any of the examples, make sure the pigpio daemon is running:

    $ sudo pigpiod

### Servos example

Watch the servos example in action here: http://youtu.be/AnlUtAq5oAM

Before running the example, please connect two servos to your Raspberry Pi.
One on GPIO18 and one on GPIO23.

Go to the examples/ directory and run the code:

    $ node js_servo.js

Watch the servos turn!

### LED PWM example

Watch the LED PWM example in action here: http://youtu.be/OW6yF4NuwLE

Before running the example, please connect to LEDs to your Raspberry Pi with
suitable resistors. Connect one LED to GPIO24 and one to GPIO25.

Go to the examples/ directory and run the code:

    $ node js_pwm.js

Watch the LEDs light up with different brightness!

Pin Layout tables
-----------------

(Tables copied from [r-pi-gpio](https://github.com/clebert/r-pi-gpio)'s readme file)

### Raspberry Pi GPIO Pin Layout (Revision 1)

| Assignment          | Pin | Pin | Assignment          |
| :------------------ | :-- | :-- | :------------------ |
| 3.3V                | 1   | 2   | 5V                  |
| GPIO 0 (I2C0 SDA)   | 3   | 4   | DNC                 |
| GPIO 1 (I2C0 SCL)   | 5   | 6   | GROUND              |
| GPIO 4              | 7   | 8   | GPIO 14 (UART TXD)  |
| DNC                 | 9   | 10  | GPIO 15 (UART RXD)  |
| GPIO 17             | 11  | 12  | GPIO 18             |
| GPIO 21             | 13  | 14  | DNC                 |
| GPIO 22             | 15  | 16  | GPIO 23             |
| DNC                 | 17  | 18  | GPIO 24             |
| GPIO 10 (SP10 MOSI) | 19  | 20  | DNC                 |
| GPIO 9  (SP10 MISO) | 21  | 22  | GPIO 25             |
| GPIO 11 (SP10 SCLK) | 23  | 24  | GPIO 8 (SP10 CE0 N) |
| DNC                 | 25  | 26  | GPIO 7 (SP10 CE1 N) |

### Raspberry Pi GPIO Pin Layout (Revision 2)

| Assignment          | Pin | Pin | Assignment          |
| :------------------ | :-- | :-- | :------------------ |
| 3.3V                | 1   | 2   | 5V                  |
| GPIO 2 (I2C1 SDA)   | 3   | 4   | 5V                  |
| GPIO 3 (I2C1 SCL)   | 5   | 6   | GROUND              |
| GPIO 4              | 7   | 8   | GPIO 14 (UART TXD)  |
| GROUND              | 9   | 10  | GPIO 15 (UART RXD)  |
| GPIO 17             | 11  | 12  | GPIO 18             |
| GPIO 27             | 13  | 14  | GROUND              |
| GPIO 22             | 15  | 16  | GPIO 23             |
| 3.3V                | 17  | 18  | GPIO 24             |
| GPIO 10 (SP10 MOSI) | 19  | 20  | GROUND              |
| GPIO 9  (SP10 MISO) | 21  | 22  | GPIO 25             |
| GPIO 11 (SP10 SCLK) | 23  | 24  | GPIO 8 (SP10 CE0 N) |
| GROUND              | 25  | 26  | GPIO 7 (SP10 CE1 N) |

License
-------

ISC - See the LICENSE file

---
_Source: https://npm.io/package/pi-hw-pwm · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
