Skip to content

pvadam/sn74hc595-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Using a SN74HC595 Shift Register with Node JS

This project is the first step towards using the SPI with Onion Omega 2. It does not yet use SPI, only controls the shift register by simple GPIO commands.

Prerequisites on Omega 2

  • Node JS (min. version: 4.0)

  • Install Onoff Node

opkg update
opkg install onoff-node

Running the project

  1. Upload the index.js file to your Omega 2.

  2. Run the Node application

node index.js

Wiring

According to this wiring diagram.

Wiring diagram for SN74HC595 with Omega 2+ using the Power Dock

Read more

Using a SN74HC595 Shift Register with SPI & Python

This is the next level using the shift register. This time we are controlling it with the Omega's SPI module.

Prerequisites on Omega 2

  • Python

  • SPI Python Module

opkg update
opkg install python-light pyOnionSpi
  • GPIO multiplexing setup properly
omega2-ctrl gpiomux set spi_cs1 spi_cs1
omega2-ctrl gpiomux set spi_s spi_s
# verifiy with the command below
omega2-ctrl gpiomux get

Note: You will not be able to use GPIO 6-9 as standard GPIOs until you set this back to GPIO mode. Read more here.

Running the project

  1. Upload the index.py file to your Omega 2.

  2. Run the Python application

python index.py

You will see the binary counter working (see the LEDs) and reading the last input back from the shift register (on the console).

Wiring

According to this wiring diagram.

Wiring diagram for SN74HC595 with Omega 2+ using the Power Dock with SPI

Read more

Cheat sheet

# Read the direction for pin 7
fast-gpio get-direction 7

# Read the value of pin 7
gpioctl get 7
# or
cat /sys/class/gpio/gpio7/value

# Set the value for pin 7 and the direction to `output`
fast-gpio set 7 0

# Read the multiplexing setup
omega2-ctrl gpiomux get

About

Programmatic control of a SN74HC595 shift register with Node JS (without SPI) and Python (with SPI) on an Onion Omega 2+.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published