Light Conductor

Views: 4360 Difficulty: 2 Status: Complete

Make an interactive light show using a proximity sensor, and a bunsh of shift registers and LEDs.

We map the input from a proximity sensor (either infrared or sonar) to an LED bar graph controlled by a 74HC595 shift register. Then we show how to control a bunch of daisy-chained shift registers using the same idea. Control a ton of LEDs by gesturing or moving back and forth in front of the sensor.

Inputs and Outputs

Proximity sensor is mapped to the LED driving shift registers.

Light Conductor Demo Video

The Light conductor code in action!

Double Video

Watch as the hand an the camera approach the sonar sensor. As they get closer they trigger more lights on the LED bar graph controlled by the 74HC595 shift register.

Light Conductor Arduino Code

This code lights the LEDs based on proximity to the distance sensor. We do an analog read on the pin where the proximity sensor is connected. Then we scale and constrain that value:
    int distance = analogRead(sensor_pin);
    int scaled = map(distance, min_in, max_in, num_registers*8, 0 );
    scaled = constrain(scaled, 0, num_registers*8);
Then we call the function light_leds(scaled) and give it the scaled value as input. This function Lights up scaled LEDs connected to the shift registers, or if you have connected the LEDs in the opposite polarity this function will light up num_registers*8 - scaled LEDs. See the entire Arduino sketch below:
/* LucidTronix Light Conductor
 * For instructions, details and schematic, See:

int clockPin = 8;
int latchPin = 9;
int dataPin = 10 ;

const int num_registers = 6;
int sensor_pin = 2;
int max_in = 600; // adjust these for different supply voltages
int min_in = 3;
boolean on = true;
unsigned long last_press = 0;

void setup() {
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);

void loop() {
    int distance = analogRead(sensor_pin);
    int scaled = map(distance, min_in, max_in, num_registers*8, 0 );
    scaled = constrain(scaled, 0, num_registers*8);
  if(digitalRead(0) && millis() - last_press > 400){
    on = !on;
    last_press = millis();
  else if(digitalRead(1) && millis() - last_press > 400){
    on = !on;
    last_press = millis();    

/*  Individual control fro all the LEDs attached to 
 *  daisy-chained shift registers
 *  Scaled is how many LEDs to light up depending on how you wire the LEDs
 *  0 is either all on or all off 8*num_registers is the opposite
void light_leds(int scaled){
    digitalWrite(latchPin, LOW);
    for (int i = 0; i < num_registers; i++){
      // three cases: all on, all off or a mix..
      if(i*8 > scaled){
        shiftOut(dataPin, clockPin, MSBFIRST, 255);
      else if ((i+1)*8 > scaled){
        int mod_8 = scaled % 8;
        byte pow_2_light = 255 >> mod_8; 
        shiftOut(dataPin, clockPin, MSBFIRST, pow_2_light);
      else {
        shiftOut(dataPin, clockPin, MSBFIRST, 0);
    digitalWrite(latchPin, HIGH);


Title Description # Cost Link Picture
Sonar Range Finder Maxbotix Sonar range finder 1 $24.95 Link Maxsonar-ez1_lrg
PCB Multi-Shift out Controls 3 different set of shift registers from analog input(s) 1 $7.0 Link Screen_shot_2013-02-15_at_6.33.34_pm
Shift Register IC SHIFT REGISTER 8BIT 16-SOP Tri-State Serial to Parallel Value: 74HC 1 $0.65 Link Screen_shot_2012-12-28_at_7.32.29_pm
LED SMD LED 3X1.5MM 568NM Green Clear SMD Value: 2.2V Green 8 $0.18 Link Apl3015sgc-f01
Standalone programmable Heart-Shaped LED display....
Two LED matrices give 70 LEDs to light up a necklace with messages....
Build your own clock with the MCP79410 chip and 4 7-Segment LED modules....
Shift Registers help you multiply your inputs and outputs....
The 74HC595 shift register controls a 10 LED Bar Graph....
Display 4 digits using only 3 MCU wires with the 4 x 7 Segment LED and shift register breakout board....
Connect shift registers together to get more output and input pins from your microcontroller....
Display numbers in big bright red LEDs use only 3 micro-controller pins and the 74HC595 shift registe...