Things used in this project

Code

Night Rider CodeC/C++
/*
Using three 74HC595s to control 24 leds (outputs) on the arduino uno. 
This is an improved version by John Rogers
*/

int latchPin = 5;   // to pin 12
int clockPin = 6;	// to pin 11
int dataPin = 4;	// to pin 14

int numLights=24;
unsigned long light = 0;  // Bit pattern for entire display
byte b1 = 0;				// byte place holders for each shift register
byte b2 = 0;				// extracted from "light"
byte b3 = 0;

	

void setup() 
{
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);  
  pinMode(clockPin, OUTPUT);
 // Serial.begin(9600);
}

void loop() 
{
	for (int i = 0; i < numLights*2; i++)
	{
		int shift = i;
		if( i >= numLights )	//if i is above numlights then wee need to start
		{						// moving back to the left.
			shift = numLights*2 - i - 1;
		}
		// Extract the bytes of the light patter to be sent out
		light = (long)(1)<<shift;
		b1 = (byte)((light>>16)&0xFF);
		b2 = (byte)((light>>8)&0xFF);
		b3 = (byte)((light)&0xFF);
		updateShiftRegister();	// shift out b1, b2 and b3
		delay(30);
	}
}

void updateShiftRegister()
{
   	digitalWrite(latchPin, LOW);
   	shiftOut(dataPin, clockPin, MSBFIRST, b1);
   	shiftOut(dataPin, clockPin, MSBFIRST, b2);
   	shiftOut(dataPin, clockPin, MSBFIRST, b3);
   	digitalWrite(latchPin, HIGH);
   	
}

Credits

Eeaaadbab52b1bceca5051c9ec1cc4fa
David A Riewe

Engineering Tech who enjoys hacking electronics, learning about new devices and programming. Founder of HackerSpaceTech

Replications

Did you replicate this project? Share it!

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Voltmeter using Arduino
Easy
  • 302
  • 12

Protip

If you can't find voltmeter at home or at any other place, then this Hack is for you, Go ahead.

Voltmeter using Arduino

Team Next Tech Lab

Save your life with the Building Collapse Monitor
Easy
  • 105
  • 4

Work in progress

Analyse concrete, metal, wood structures for bends and angles and alerts if they have deviated from the original position.

Hackster Live April 2017 Workshop - Optional - Easy Add-on
Easy
  • 83
  • 2

Full instructions

Adapt your home automation project from our March 2017 workshop to be controlled through BLE using the Blynk app on your phone.

near-perfect gyroscope
Easy
  • 483
  • 7

Work in progress

this code lets you make an accelerometor & gyroscope give the best results.

Arduino 101 - Intel Curie Pattern Matching Dress
Easy
  • 2,119
  • 19

Full instructions

A dress with Curie's pattern matching engine on Arduino101 to control the embedded LEDs, which makes constellations show up on the dress.

Arduino Morse Code Machine
Easy
  • 755
  • 11

Full instructions

A simple arduino Morse code machine with a button,led and a buzzer that takes your input and translates it into English while you are typing

ProjectsCommunitiesContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login
Respect project
Feedback