0.1.0 • Published 11 years ago

shift_register.cpp v0.1.0

Weekly downloads
4
License
-
Repository
github
Last release
11 years ago

Shift Register (74HC595)

This is a dotc enabled C++ module for using the 74HC595 shift register.

Installation

npm install shift_register.cpp

Usage

#require "shift_register.cpp" as ShiftRegister

ShiftRegister sr(10,11,12);

void setup() {
  sr.setup();
}

uint8_t pattern = {HIGH, LOW, HIGH, LOW, HIGH, LOW, HIGH, LOW};

void loop() {
  sr.writeAllPins(pattern);
  sr.writePin(3, HIGH);
}

API

ShiftRegister(uint8_t srclk, uint8_t rclk, uint8_t ser)

These are the pins as they corospond to the datasheet.

void ShiftRegister::setup()

This simply sets the pin mode on each of the pins passed to the constructor to output so the class can write to them safely.

void ShiftRegister::writeAllPins(uint8_t[8] output)

This takes an array of 8 values and writes them out to the output pins. It replaces whatever is already in the shift register at the time.

void ShiftRegister::writePin(uint8_t pin, uint8_t value)

This takes the 0 indexed pin to write to, and the value to write to it, then it immediately writes it out. It leaves all other pins in the state they were in before writing.

0.1.0

11 years ago

0.0.5

11 years ago

0.0.3

11 years ago