Welcome to Light Snake’s documentation!¶
Introduction¶
This light sculpture was build in 2013/2014. It is the one of the first LED projects from Klingdesign.
Klingdesign is the light artist Christiane Kling. She produces tailor made light sculptures. Since 2013 the electronic engineer Günther Beulen has been joining Klingdesing. He develops Hard- and Software. And this is their first big project:

To see the light snake in action, here is the Youtube video.
Hardware¶
This light sculpture includes 15 power LEDs. Each power LED has its own current source.
Each current source contains a NE555 working as a two-level controller. The average value of the current is 300 mA. The pin 4 of a NE555 is a reset pin, which can be used for intensity control via PWM. The next photo shows the LTspice model, which is available in the repository.

To control all 14 current sources the Adafruit PCA9685 16-Channel Servo Driver, based on the IC PCA9685, is used.
This IC is controlled by an Arduino Uno. This board is based on the ATmega328P.
Software¶
The software was written with the Arduino IDE. The library Adafruit-PWM-Servo-Driver-Library handels the PCA9685. It is available from the Arduino library manager.
Communication¶
Bluetooth¶
Serial Communication¶
The serial communication is possible with the USB port of the Arduino Uno or with the RX/TX pins of the controller.
It is possible to debug the light sculpture. Each LED can be tested. If it is currently on the PWM control may be defective and if it is currently off than the LED or the current source may be defective.
Class LightSnake¶
-
class
LightSnake
¶ Public Functions
-
void
setup
()¶ This function initializes the LightSnake class.
The class contains one instance of the class Adafruit_PWMServoDriver and an array of the class Led. The random generator and the class Serial will be initialized, too.
-
void
loop
()¶ This function repeats the updates of the intensites of the leds.
Every element of the Led Class is called. Their intensities are updated and at the min or max value a new duration of the speed is evaluated. The new intensities are send via the I2C bus to the PCA9685.
-
void
help
()¶ This method prints an info.
The Serial Monitor of the Arduino IDE, PuTTY or picocom can be used.
-
void
info
()¶ This methode prints the info of all Leds.
The number, intesity, darker and duration of all LEDs are printed. And the time each the last loop has needed and the cycle time of the loop.
-
void
clearAllLEDs
()¶ Clear all LEDs.
All LEDs are cleared by sending the intensity Zero to each chanel of the PCA9685
-
int8_t
getNumber
()¶ This method is used by getting the number of a LED and by getting the new duration.
- Returns
number
-
void
getLEDNumber
()¶ Gets he number of the LED to test.
Get the number of the LED to test. Hexadecimal number are used (0..9, A, B, C, D). X will delete this loop.
-
void
testLED
(uint8_t)¶ This method tests the specified LED.
First all LED are turned off. After waiting for a second, the specified LED is turned on for a second and then turned off. So the hardware can be tested. The Serial Monitor of the Arduino IDE, PuTTY or picocom can be used.
-
void
testAllLEDs
()¶ This method tests the LEDs and their current sources.
Every LED is beeing tested after this method is called. First all LED are turned off. After waiting for a second, every LED is turned on for a second and then turned off. After waiting for a second, the next LED is turnde on and off. So the hardware can be tested.
-
void
invertOutputOfLoopDuration
()¶ This method handels the output of the loop time.
The output of the looptime, the duration of an cycle, can be enabled or disabled. Every time when this method is called, the corresponding boolean varialble is inverted.
-
void
changeLoopDuration
(bool)¶ This method sets a new duration time for the loop.
The time sets the duration for the loop. If this value is to small, the function will not wait and start immediately with the next cycle. After each cycle the methods waits till the duration of a cycle is over. A loop duration can be set with a char. This character represent a hexadecimal digit. Hexadecimal number are used (0..9, A, B, C, D, E, F). The new duration time is this digit multiplied by 5 ms. At the end of the loop, the output of millis() is polled. If the value 0 is choosen, the next loop starts immediately.
-
void
setIndex
(bool)¶ This methods sets the beginning of an array.
There can be different arrays containing the intensities. With this method the index of the progmem is set globally for all LEDs.
-
void
readEeprom
()¶ This method reads the content of the EEPROM.
The user can set the cycle time and the index of the used PROGMEM. The setup function can read the stored values. If a 255 is read, than the EEPROM has not been programmed yet. Than the cycle time and the index are set to default values.
-
void
writeEeprom
()¶ This methods writes the current values to the EEPROM.
If the user changed the loop time and the PROGMEM index, he can save this to the EEPROM. So they will be loaded at the next start.
-
void
Class Led¶
-
class
Led
¶ Public Functions
-
uint8_t
getNumber
()¶ - Returns
the number of the LED
-
void
setNumber
(uint8_t)¶ - Parameters
number – of the LED
-
uint16_t
getIntensity
()¶ - Returns
intensity of the LED
-
void
setIntensity
(uint16_t)¶ - Parameters
intensity – of the LED
-
uint8_t
getPointer
()¶ - Returns
pointer to the intensity table
-
void
setPointer
(uint8_t)¶ - Parameters
pointer – to the intensities
-
uint8_t
getProgmemIndex
()¶ - Returns
pointer to the intensity table
-
void
setProgmemIndex
(uint8_t)¶ - Parameters
pointer – to the intensities
-
bool
getDarker
()¶ - Returns
darker of the LED
-
void
setDarker
(bool)¶ - Parameters
darker – if the brightness of the LED decreases
-
void
invertDarker
()¶ inverts darker
-
bool
getWaitAtMinIntensity
()¶ - Returns
waitAtMinIntensity
-
void
setWaitAtMinIntensity
(bool)¶ - Parameters
waitAtMinIntensity – this LED waits at its ninimal brightness
-
bool
getWaitAtMaxIntensity
()¶ - Returns
waitAtMaxIntensity
-
void
setWaitAtMaxIntensity
(bool)¶ - Parameters
WaitAtMaxIntensity – this LED waits at its naximal brightness
-
uint8_t
getCyclesAtMinIntensity
()¶ - Returns
cyclesAtMinIntensity of the LED
-
void
setCyclesAtMinIntensity
(uint8_t)¶ - Parameters
cyclesAtMinIntensity – this LED waits this cycles at its ninimal brightness
-
uint8_t
getCyclesAtMaxIntensity
()¶ - Returns
cyclesAtMaxIntensity this LED waits at its ninimal brightness
-
void
setCyclesAtMaxIntensity
(uint8_t)¶ - Parameters
cyclesAtMaxIntensity – this LED waits this cycles at its maximal brightness
-
bool
getDarkerHasChanged
()¶ - Returns
_darkerHasChanged
-
bool
getIntensityAtMin
()¶ - Returns
_intensityAtMin
-
bool
getIntensityAtMax
()¶ - Returns
_intensityAtMax
-
void
increaseIntensity
()¶ Increases the intensity.
If the new intensity is equal to the maximal intensity, the intensities will be decreased in the next step.
-
void
decreaseIntensity
()¶ Decreases the intensity.
If the new intensity is equal to the minimal intensity, the intensities will be increased in the next step.
-
void
changeIntensity
()¶ Increases or decreases the member _intensity.
In dependency of the boolean value of darker the method increaseIntesity or decreaseIntensity is called.
-
void
increasePointer
()¶ Increases the pointer to the intensities.
If the new value of the pointer is equal to the size of the array, the pointer will be decreased in the next step;
-
void
decreasePointer
()¶ Decreases the pointer to the intensities.
If the new value of the pointer is equal to zero, the pointer will be increased in the next step.
-
void
changePointer
()¶ Increases or decreases the pointer.
In dependency of the boolean value of darker the method increasePointer or decreasePointer is called.
-
void
pointer2int
()¶ The array with the intensitys is included in the header file ‘
intensities.h’. This file has been created by the python script ‘progmen_creator.py’.- Returns
the content of the PROGMEM array.
-
bool
letSpeedControlCount
()¶ Call counter method of class SpeedControl.
The property counter of the aggregated class SpeedControl is decreased. If its value is equal to zero, true is returned. The variable is the initialized with the duration.
-
void
setSpeedControlDuration
(uint8_t)¶ - Parameters
duration – time at one intensity (property of the class SpeedControl)
-
uint8_t
getSpeedControlDuration
()¶ - Returns
duration (the time at one intensity, property of the class SpeedControl)
-
void
setSpeedControlCounter
(uint8_t)¶ - Parameters
counter – If a longer duration is wanted, the counter can be set to a value greater than duration.
-
uint8_t
getSpeedControlCounter
()¶ - Returns
counter counts from duration to zero
-
uint8_t
Class SpeedControl¶
-
class
SpeedControl
¶ Public Functions
-
uint8_t
getCounter
()¶ - Returns
counter
-
void
setCounter
(uint8_t)¶ - Parameters
counter – of the LED
-
uint8_t
getNumber
()¶ - Returns
number of the LED
-
void
setNumber
(uint8_t)¶ - Parameters
number – of the LED
-
uint8_t
getDuration
()¶ - Returns
duration of the entensity
-
void
setDuration
(uint8_t)¶ The duration specifies the time at an intensity
- Parameters
duration – of the intensity
-
bool
count
()¶ The method decreases the counter, if the counter has the value zero, true is returned.
- Returns
(counter == 0)
-
uint8_t