shiftregister 74hc595

shiftregister 74hc595

Mit 3 Kabel, Anzahl x Led’s, am Arduino ansteuern.

das Shift Register Breakout – 74HC595 mit Hardware SPI

Demo (8 x Led & 1 x 7 segment) mit 2 x 74HC595

#include <SPI.h>
//                      Mega2560  74HC595  ARDUINO SPI
int dataPin = 11;       // 51     SER    =   MOSI
int latchPin = 10;      // 53     RCLK   =   SS
int clockPin = 13;      // 52     SRCLK  =   SCLK

int N1[9] = {63,6,91,79,102,109,124,7,127};
int N2[9] = {0,1,3,7,15,31,63,127,255};

void setup()
{
  pinMode(latchPin, OUTPUT);   
  digitalWrite(latchPin, LOW);
 
  //Setup SPI
 SPI.setBitOrder(MSBFIRST);
 SPI.begin();  
}

void loop() {
   for (byte i=0; i < 9; i++)
    {
      writeOutput(N1[i], N2[i]);
      delay(500);
    }
}

void writeOutput(int b1, int b2)
{
    digitalWrite(latchPin, HIGH);  // Pull latch LOW to send data
    SPI.transfer(b1);
    SPI.transfer(b2);
    digitalWrite(latchPin, LOW);   // Lower the latch to apply the changes
}

breakboard_74hc595
5/5 - (1 vote)
Andreas

Hinterlasse einen Kommentar

WP2Social Auto Publish Powered By : XYZScripts.com