I brought a “Funduino Keys 595” board from dxlisting, Basically its a 74HC595 shift register with 4 RGB LED’s on it. The page said it was a SPI device. I did not know anything about the shift register until it arrived and I saw some non SPI markings on it. I did some digging to find the shift register was not SPI, and that I could use a simple wiringPi library on the Raspberry Pi to control it. Also there was no documentation as to how the LEDs were configured.
Hooking this up to the Raspberry Pi was easy enough..
Connected the following pins.
Raspberry Pi | Keyes 595 |
Pin 1 3v3 | VCC |
Pin 6 GROUND | GND |
Pin 11 GPIO17 | SDA |
Pin 12 GPIO19 / CLK | CLK |
Pin 13 GPIO27 | STB |
Then using the example from wiringPi, I modified it So I could enter the bit number and the state (0/1). This is the source. Save it as shift.c.
/*
* shift.c:
* Shift register test program
*
* Copyright (c) 2012-2013 Gordon Henderson. <projects@drogon.net>
***********************************************************************
*/
#include <stdio.h>
#include <wiringPi.h>
#include <sr595.h>
int main (void)
{
int i, bit ;
char input[255];
wiringPiSetup () ;
// Pin base 100 for 10 pins.
// Use wiringPi pins 0, 1 & 2 for data, clock and latch
sr595Setup (100, 10, 0, 1, 2) ;
printf (“Raspberry Pi – Shift Register Testn”) ;
for(i = 0; i < 8; i++){
digitalWrite(100+i,0);
}
for (;;)
{
printf(“Enter bitn”);
scanf(“%d %d”,&bit,&i);
digitalWrite(100+bit,i);
}
return 0 ;
}
at the prompt enter a bit number then 1 or 0 eg (you enter the bold)..
Raspberry Pi – Shift Register Test
Enter bit
1 1
Enter bit
3 1
Enter bit
Bit | LED |
0 | Not Connected |
1 | Left – Blue |
2 | Left – Red |
3 | Left – Green |
4 | Right – Blue |
5 | Right – Red |
6 | Right – Green |
7 | Not Connected |
Link to the funduino product site.
That is all on that for now..