Ambilight System for Every Input Connected to Your TV. WS2812B Arduino UNO Raspberry Pi




I have always wanted to add ambilight to my TV. It looks so cool! I finally did and I was not disappointed!

I have seen many videos and many tutorials on creating an Ambilight system for your TV but I have never found a full tutorial for my exact needs.

It is whether the system is only made for 1 single source (PS4 or Xbox or TV etc..) or it is not using the same LED's as I wanted to use, so I decided to create an instructable and put together all the information and experience I gathered in one spot while making this project.

The system I have made can be connected to up to 5 different sources. I have it setup here to run with my PS4 system or my home theater/blu-ray player or my Foxtel (Australian cable tv box) or my computer and have a spare input left for something else. All of these simply with the press of a button.

I have added a LCD screen to display the current source being connected to the ambilight and an ON/OFF button for the system.

If you are looking to have ambilight available for every different inputs connected to your TV, want to use the WS2812 type led strips, then look no further, this tutorial is for you.

I have entered this instructable into the Raspberry PI 2016 contest so if you like it please drop me a quick vote! Much appreciated in advance.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Material Needed to Build This System

Not all of the sources have an HDMI output, like my computer is still connected through the old VGA connector and my Foxtel unit is still connected via AV cables. I had to purchase quite a few different adapters to get it all working, but in the end the result is awesome and well worth it!!

Not everything here will be needed depending on your own system and if you would like a LCD or not. I will separate the optional items.

  1. 1x 4meter strip of WS2812B 60leds/m. (this was enough for my 55inch tv) I have bought mine from Aliexpress. LED strip
  2. 1xArduino UNO board.
  3. 1x Raspberry Pi model B+.
  4. 1x SD card. (8Gb is good)
  5. 1x Video grabber type STK1160. (be carefull when chosing the grabber, some models will not work!!) This is the one I got and it works correctly. Video grabber
  6. 1x 5V 10amps power supply. I got mine from Aliexpress again and it works fine. Power supply
  7. 1x HDMI splitter 1 x 2. splitter
  8. 1x HDMI switcher 5 in 1. switcher
  9. 1x HDMI to AV converter. converter

cables and hardware:

  1. 4x 25cm HDMI cable. cable
  2. 2x HDMI female to female enclosure connectors. connector
  3. 1x 220V input connector (fused).
  4. 1x project enclosure (can be different, it is up to you, mine is 424mm x 203mm x 86mm) box
  5. Single core wire to connect the 5V to the different converters etc.
  6. Ribbon cablesor extensions to wire inputs to the Arduino exemple

optional extras:

  1. 1x AV to HDMI converter. converter
  2. 1x VGA to HDMI converter. converter
  3. 2x 25cm HDMI cable. cable
  4. 1x LCD display 16characters x 2lines. LCD
  5. 1x I2C interface for the LCD. interface
  6. 1x cooling fan for the case.

Step 2: What Computer Programs Will Be Required

There will be a few different programs required for this project.

You need to download and install them (if you don't already have it)

  • WinSCP can be downloaded here
  • Putty can be downloaded here (click on the putty.exe link in the list)
  • SDFormatter can be downloaded here
  • Win32DiskImager can be downloaded here
  • Arduino IDE can be downloaded here (I used version 1.6.5 at the time)
  • HyperCon can be downloaded here (click on the clone or download link)
  • Notepad++ (optional) can be downloaded here

You will need to download the Raspberry Pi disk image too. Chose the file named "OpenELEC 5.0 with STK1160/UTV007 compatible kernel RPI 1"that you can download from the bottom of the page here

Step 3: Getting the Raspberry Pi Up and Running

We are going to start by getting the Raspberry Pi up and running.

1) We are going to write openELEC to the SD card.

  1. Unzip the Raspberry Pi disk image.
  2. Plug the SD card into your computer.
  3. Run the SDFormatter program.
  4. Select the SD card drive letter.
  5. Click on option and select "size adjustment" to ON.
  6. Click OK.
  7. Click Format.
  8. Run the Win32DiskImager program.
  9. Select the Raspberry Pi image and the drive letter of your SD card.
  10. Select Write.

2) Eject the SD card from your computer and plug it in your Raspberry Pi.

Connections to be made on the Pi:

  • Connect an Ethernet cable to your Pi from your network.
  • Connect the HDMI port of your Pi to your TV or screen.
  • Plug in a keyboard and a mouse on the USB ports. (I use a wireless mouse and keyboard combo and I have left the dongle connected to the Pi, this way, now that the Pi is boxed up, I don't have to open it all up if I want to access my Pi.)
  • Plug in the usb end of the video grabber to your Pi.

3) Connect a 5V power supply to your Pi and follow the onscreen information until it boots up. You should be presented with a screen as per my photo.

We now need to check your internet connection. Follow the path SYSTEM - openELEC - system info and write down your IP address, it will be needed in the future.

While in the menu, follow the path SYSTEM - openELEC - services and scroll down until you find the tab called SSH. Put a tick into the Enable SSH.

Now we are going to install Hyperion and check our video grabber connection to the Pi.

For this we are going to use Putty. Your Pi has to be powered ON and connected to your network for this to work.

  • Type in the IP address you wrote down just before for your Pi. as per picture attached and click Open.
  • You should then be prompted with a window asking you for a username as per picture attached. type in root and press enter.
  • you will then be asked for a password. (note that the characters wont appear while typing the password, this is normal). Type in openelec and press enter.
  • To check all the usb ports, type in lsusb and press enter. You should find your video grabber in the list as per the picture attached.

While Putty is open, we are going to install Hyperion, this is the software running on the Raspberry Pi that is going to take care of transforming our video signal into the correct sequence to be sent to our led strip.

  • copy the following link and use the right click of your computer mouse onto the putty window to paste the link and start the process. curl -L --output --get sh ./

This complete the Raspberry PI setup. We will get back to it later on to upload our LED's configuration file.

Step 4: Hyperion and the Configuration File

!!!UPDATE!!! If your version of HyperCon contains 5 tabs, please refer to step 13 for programmation.

  • Start by opening the program HyperCon.jar.

You can simply copy the first 4 lines in the Hardware tab.

  • The direction is which direction the strip is running when you are looking at it from the screen side of your TV.
  • If like me, you have put LED's in the top and bottom corners, you have to select true for the next 2 lines.

If you select true to both of them, you have to take 1 away from your total number of LED's on the vertical axis.

(i have 47 LED's on each side vertically, with 2x true = 45 LED's for the count)

  • You can then fill up the next 3 rows according to your setup and paying attention to the comment above.
  • The bottom gap is simply the results of "horizontal number of LED" - how may LED's you have at the bottom of your TV. In my case 78 at the top, 30 each side at the bottom = 18 gap
  • Increase or decrease the offset number until the LED 0 on the right part of the screen matches the start LED of your own setup.
  • You can as well copy all the fields under Image Process according to my picture, it works well and can always be modified later if needed.
  • Once you are done, the number of LED's indicated on the right of the screen should be the same as the number of LED's physically stuck to your TV.

Now moving to the Process tab.

  • Make sure the frame grabber is ticked. set the height and width to a value of 3x your actual number of LED's. It works well. Again, this can be later modified if needed but is a good start. Copy the 25Hz as well
  • Enable the smoothing and copy the values from my setup.
  • Copy as well the Color values I have on my picture, they are a good starting point and work quite well.

To finish, move onto the External tab.

  • Everything in this tab can stay untouched except the highlighted field that you need to copy according to mine.

You can nowclick on the "create hyperion configuration" button and save the file somewhere easy.

I use Notepad++ to open the configuration file as this program works well for me.

We are now going to open the configuration file and add a few lines in it for hyperion to work with our frame grabber.

You can refer to the picture above for visual help.

  • Scroll all the way down the file.
  • Delete the last 2 lines as per the highlighted part on the picture.
  • Now copy the following lines from here under and paste them in your file at the end

/// Configuration for the embedded V4L2 grabber
/// * device : V4L2 Device to use [default="/dev/video0"]

/// * input : V4L2 input to use [default=0]

/// * standard : Video standard (no-change/PAL/NTSC) [default="no-change"]

/// * width : V4L2 width to set [default=-1]

/// * height : V4L2 height to set [default=-1]

/// * frameDecimation : Frame decimation factor [default=2]

/// * sizeDecimation : Size decimation factor [default=8]

/// * priority : Hyperion priority channel [default=800]

/// * mode : 3D mode to use 2D/3DSBS/3DTAB (note: no autodetection) [default="2D"]

/// * cropLeft : Cropping from the left [default=0]

/// * cropRight : Cropping from the right [default=0]

/// * cropTop : Cropping from the top [default=0]

/// * cropBottom : Cropping from the bottom [default=0]

/// * redSignalThreshold : Signal threshold for the red channel between 0.0 and 1.0 [default=0.0]

/// * greenSignalThreshold : Signal threshold for the green channel between 0.0 and 1.0 [default=0.0]

/// * blueSignalThreshold : Signal threshold for the blue channel between 0.0 and 1.0 [default=0.0]

"grabber-v4l2" :


"device" : "/dev/video0",

"input" : 0,

"standard" : "no-change",

"width" : 1,

"height" : 1,

"frameDecimation" : 2,

"sizeDecimation" : 4,

"priority" : 1100,

"mode" : "2D",

"cropLeft" : 0,

"cropRight" : 3,

"cropTop" : 6,

"cropBottom" : 17,

"redSignalThreshold" : 0.0,

"greenSignalThreshold" : 0.0,

"blueSignalThreshold" : 0.0


"endOfJson" : "endOfJson"


One word now on this video grabber's setup we have just added to our configuration file. This step will need to be done when everything is working and finished.

The 4 lines: Crop Left , Crop Right, Crop Top, Crop Bottom. These values need to be changed according to your setup. Start with all these four numbers with a value of 0 and load the config file back into your Pi. Reboot your system and watch some TV. If on the left side of your TV the LED's are not lit up you need to increase the value under "Crop Left" and try again until the LED's light up.

You can then repeat the process with the 3 other sides.

Success!!! I know it is a bit time consuming but it insures you are not cropping too much of the image off on one side or the other but just what is necessary.

Step 5: Getting the LED's on the Back of the TV

This step speaks for itself, it is time to put the LED strip at the back of the TV.

I personally just used the double sided tape of the LED strip and glued the strip on the edge of my TV. Some people prefer and build a frame for the LED's. This is all up to you and your TV as they will most likely always be different.

My setup has 78 LED's at the top, 47 on either sides and 30 on either sides at the bottom of the TV for a total of 232 LED's.

When I face my TV, the LED strip is running clockwise, this is looking at where the signal is getting to the first LED and travelling through until it reaches the last one.

Remember that there will potentially be a fair bit of current running through the strip, depending on its size, this is why I ran the power on both ends of the strip. The connecting wires on the edges of the TV will have to be big enough as well to pass this current through.

I used the connectors supplied with the LED strip. One connector (where the strip begins) has 3 wires, +5V and GND and as well the Data IN. The other side of the strip only has 2 wires. +5V and GND.

Step 6: Uploading the Hyperion Config to the Raspberry Pi

For this step, your Raspberry Pi needs to be powered ON and connected to your network. We will use WinSCP to load up the file into the Pi.

  • Start by opening the program and entering the IP address under Host name, user name root and password openelec into the field as per the picture attached. Click login.
  • You should then see a window with a few lines as per the second picture while it is logging in.
  • You will then be presented with a window as per the picture above. The left side is your personal computer and the right side is the Raspberry Pi.
  • On the left side, navigate through until you have the configuration file located.
  • On the right side, double click on the return arrow couple of time until you are in the root menu ( only a / in the address bar above) the double click onto storage to get into this menu.
  • Select the config file on the left and click F5 or click onto the Upload button above it.
  • You will then have an upload window as per the picture. You need to copy the path storage/.config/ and the press ok.

Your hyperion config file is now loaded into your Pi. You can reboot it and it will now use this new config file when it restarts.

Step 7: How It All Works

You can refer to the organization chart I have drawn, a picture is worth a thousand words.

Brief explanation:

The HDMI switcher will pass through to its output 1 out of the 5 input signal it receives, as selected by you. (Playstation, Xbox, tv, etc...)

This signal is then fed into the splitter, which will duplicate the signal.

The first output of the splitter is going straight to your TV, to display the image as per usual.

The second output of the splitter is fed into the HDMI to AV converter.

The signal is converted and passed through to the video grabber. (via the yellow connector. Red and white are not needed, they carry the sound).

The raspberry Pi will in turn take the data from the video grabber, process it and send through to the Arduino the color that each LED will have to take.

The Arduino will then output the data to the LED's.

The Arduino is as well monitoring the HDMI switcher and according to the channel selected on the switcher, it will update the LCD screen to display the correct source. It monitors the ON/OFF button too which allows the led strip to be turned OFF if not needed.

Step 8: Boxing Up the Project and Connecting the Different Parts.

The boxing up of your project will be up to you. I have tried to put as many comments as possible on the pictures to give you and idea of how my setup is put together.

One very important thing is to make sure the video grabber input to the Pi is not connected with anything else, I had frame size errors and a lot of other weird things happening when I had anything else connected to the other USB port. It must reach a bandwidth limit or something but it would not work when I tried plugging in a WiFi dongle in this USB or even the output cable going to the Arduino.

I recommend placing all the converters etc and starting by bringing power to all of them first. Most of these converters came with a wall plug power pack. I cut off the cable and only used the connector on the converter's side and decided to build a little board with a lot of +5V and GND connections to power them all from. It saved a lot of room.

I stuck the different converters down with 2 component glue and used plastic stand offs to bolt the Arduino down. I added some glue to the back of the IEC connector as well for a bit of added rigidity. My IEC connector has an inbuilt ON/OFF switch that I can use to power off the whole unit. It has as well a fuse draw where I have put a 1.6A /250V fuse for protection if anything had to go bad with my cheap power supply.

I used my dremel tool and some files to make the openings into the enclosure and make it look nice. I have as well carved an opening for the IR sensor at the front of the enclosure above the LCD.

I have not drawn a proper schematic drawing for the wiring to the Arduino, let me know if someone would prefer to have one instead of using the picture one I have made up.

Don't hesitate to comment if needed and I will happily answer questions and update this instructable to make it more complete or easy to understand.

Step 9: Hacking Into the HDMI Switcher (optional)

For our Arduino to tell which source the HDMI switcher is actually displaying, we need a way to send this information from the switcher to the Arduino. Luckily, the switcher the switcher has 5 LED's to display source 1 through to 5 when selected and we are going to use these signals for the Arduino.

I have taken a signal from the 5 LED's but later when I wrote the Arduino code, I realized that I did not need a signal from the LED number 1, if you look closely at the ribbon cable connection to the Arduino, you can see that the brown wire on the right hand side is actually not connected. We only have LED2 connected to A0, LED3 to A1, LED4 to A2 and LED5 to A3.

I connected them to the Analog inputs for no other reasons that convenience of the wiring into my project box.

If you decide to build this project and do not want to have an LCD display on the front panel, this step is not needed and can be skipped. It will be hard to know which source is selected on the HDMI switcher if the LED's on it are out of view like in my project design where the switcher is housed inside the enclosure.

Step 10: The Arduino and Arduino Code

For the Arduino sketch to compile properly you will need 2 libraries:

Adafruit_NeoPixel.h that you can download here

LiquidCrystal_I2C.h that you can download here (version 2.0)

I have tried to add as many comments as possible through the code. If anything is unclear, don't hesitate to post a comment and ask questions. They can help a lot of people.

Having a look through the code that I have attached to this step.

Here you can select a start color for the LED strip to light up at startup

#define STARTCOLOR 0xff8000

Datapin is the pin selected where the Din of our LED strip will be connected

#define DATAPIN 5

Led count is the actual number of LED's in your system

#define LEDCOUNT 232

The baudrate must not be changed, or it will need to be changed in the Hyperion config file too

#define BAUDRATE 500000

This is the brightness level you want your LED strip to operate at. Testing required in your environment. 0 to 100 selection

#define BRIGHTNESS 90

This line below is probably the hardest thing to understand and has to be modified to work in your setup.

const char prefix[] = {0x41, 0x64, 0x61, 0x00, 0x??, 0x??};

Start by taking the first 4 bytes, it never changes. So you can already write const char prefix[] = {0x41, 0x64, 0x61, 0x00, and it will be correct.

This is not that bad in the end. For the 5th byte. In my system I have 232LED's. The 5th byte calculation is to substract 1 from my LED number and transform the result in HEXADECIMAL value. 232 - 1 = 231. 231 in HEX = E7

Now we have to deal with our 6th byte. It is an "exclusive OR" function or XOR function between to numbers. The first number will be 55 and this never changes. The 2nd number is your calculated 5th byte. In my case it is E7.

Use the following 5th and 6th bytes in the line of code, replacing the ?? and you are done.

At the end of the code, in the check_source() routine, this is where you can change for each source the information that is going to be displayed on the LCD when the source is selected like TV or PS4 or computer etc etc...

You can set the LCD cursor as well to have the printed name printed in the center of the LCD.

Once you are happy with your code you can upload it to your Arduino and check that it works correctly with at least the LCD for now.

Note that it will take a good 20 seconds to start as I added long delays at the beginning of the code to avoid having strange reboots of the Arduino while the Raspberry Pi was booting up. So don't be afraid if nothing shows up on the screen straight away. One way to tell the code is running is the LED of the ON/OFF button should light up at startup.

Step 11: Bringing It All Together and Testing

Raspberry Pi and Arduino can now be linked with the USB cable.

LED strip has been connected to the enclosure and to the Arduino.

Arduino and Raspberry are programmed.

5V supply from the power supply is going to all the different converters Arduino and Raspberry.

When power is applied to the project box, the HDMI switcher LED source is light up, Source channel can be change by the mean of the remote control or button on the switcher.

Select the source on your TV where you connected the main cable from the project box output and see if you are getting an image on the screen from whatever source you have selected on your switcher.

After a few seconds, the LED strip should progressively light up and the switch off. This mean the Arduino has started and the connection with the LED strip is good.

Soon after, the LED strip should start displaying colors as per the information passed on by the Raspberry.

Succes!! You have now finished your project and can start enjoying some entertaining TV light show!

Step 12: Control Your LED Strip From Your Phone

To add a bit of fun to this, you can download an App on Iphone, I am sure it must be available for other devices as well.

Very easy to use, just make sure your Pi and LED strip are ON and press the Detect button on the top left. It should detect the Server, that you can name as you wish to.

Select it and you are all set, you can pick colors from the color wheel and your strip will light up accordingly or chose from different effects to be displayed.

Step 13: Update for the New HyperCon Program

As some of you have stated in the comment section, Hyperion have come out with a new version of HyperCon which contains more settings to create your hyperion config file.

If you are using this new program you will need to skip Step 4 and do this one instead.

Start by opening the program HyperCon.jar.

I have added as much info as possible on the pictures, you can refer to them to help you through the setup.

Under construction, if you select LEDs in the corners of your TV, like me, you will have to substract 2 to your actual numbers of LEDs on the Left and 2 on the right side of your TV.

On my TV, I have 47 LEDs on each sides but I had to write 45 in the boxes to account for the corner LEDs added.

As a control, on the bottom right corner of the HyperCon window, the numbers of LEDs shown should match up to your physical number on your TV.

At the bottom of the HyperCon page, you have a help/wiki button. It will bring you to a nice page with all relevant infos and explanations on the different possible settings if needed.

Once your configuration is complete, you can click the "Create Hyperion Configuration" button and save the file somewhere handy.

Raspberry Pi Contest 2016

Second Prize in the
Raspberry Pi Contest 2016

20 People Made This Project!


  • Indoor Lighting Contest

    Indoor Lighting Contest
  • Make It Fly Challenge

    Make It Fly Challenge
  • Growing Beyond Earth Maker Contest

    Growing Beyond Earth Maker Contest

116 Discussions


6 weeks ago

Where did you get such big project box? This is a very nice project. I have been thinking for quite some time now how to box up my setup and just now I came across this, perfect!

2 replies

Reply 5 weeks ago

Wow thanks, that link is exactly what I needed. The link you provided linked me to the Farnell manufacturer website in my country with the same enclosure you have for about 25 euro's.


Question 4 months ago

Hi pfoglietta! That's a great instructable!! I have a doubt: is it possibile to plug the HDMI OUTPUT of the TV into the splitter, in order to also have the TV signal itself as one of the possible inputs for the raspberry? Then the TV source will not be set to HDMI, but, for example, to the antenna, the decoder, Netflix or whatever.. thanks!


Question 5 months ago

Os it possible to create a ambilight for tv and hdmi sources. For example if i am watching tv and the ambi works then i switch to my ps4 and the ambi automatically switches


2 years ago

Great work, thanks! I have some questions. I am watching TV only from my TV box - iconbit xds73d mk2. My tv box has component video out and if I'm right, then I do not need to use an HDMI converter??

In my mind: iconbit xds73d mk -> Easy Cap -> Raspberry Pi -> Arduino -> LED Strips. All of it connect to 5v20a power supply.

1 reply

Reply 11 months ago

Hi buddy, Your idea should work, but I don't see any sources in the whole internet which can confirm this. I am even equally curios to try your method. If your method really works then there are HDMI Out ports to tv sets. There is no need for trying to add multiple input support as we get the output directly from the tv set.


1 year ago

Did you install a diode to prevent reverse current whenever the device is off but plugged in.?

1 reply

1 year ago

The specific version of of the RPI disk image suggested, "OpenELEC 5.0 with STK1160/UTV007 compatible kernel RPI 1," no longer seems to be listed at the given link, and none of the updated version mention the STK1160/UTV007. Can you suggest either an alternative source or which updated version would be the correct analog? Thank you.


2 years ago

Hey guys, can anyone please help me with installation? Here is the situation: I connected ws2812b led strip with arduino uno, arduino uno with raspberry pi b+ via usb, video grabber(UTV007) to raspberry and on video grabber hdmi2av adapter. I made config files by the instructions and when i turn everything on, leds only turns on for about 10sec (orange colour) and then they turn off...what could be wrong? I have tried several openelecs, different arduino sketches and nothing worked. It seems like arduino is getting some information from raspberry, because when I connect video grabber to rspb, on arduino red light starts flashing as it would be processing something. Any suggestions?

3 replies

Reply 1 year ago

I have the leds turning off after the boot sequence with nothing else afterwards as well. Hyperion logs show ok, Android app/hyperion-remote working good, Arduino led flashing continously but no LEDs. Have you managed to fix your issue ? If so, how did you ?


Reply 2 years ago

Hey, did you manage to get ambilight to work? I have installed different sketch on arduino form this site :

and it works now. Than you need to increase some values for the led strip to work flawlessly and I had to change led type from RGB to GRB in hyperion file. Give it a try and let me know. I hope it Works:)


Question 1 year ago

Wow, this is by far the best tutorial I have seen on this topic!

I still have two questions:
1. Can you switch the LEDs off? If yes, how would you do so? Is it possible to send a command via web interface (Smartphone -> Raspberry Pi -> Arduino) or something similar?
2. If I am watching a movie on Kodi (installed on Raspberry Pi) and playing with my PS4, how does the Raspberry Pi know what video signal to use in order to control the LEDs? Is it as simple as switching the source on my TV (HDMI Splitter output/Raspberry Pi output)?

Thanks in advance!


1 year ago

What a great tutorial....and in great English too!!

I'd love to try this....and have a couple of Q's.

My HDMI sources will be 4K....does that influence choice of components?

Can Raspberry Pi 3 model B be used?

Many thanks from the UK!!


1 year ago

hey there,

i would be happy, if someone could help me with the following problem. I wanted to upload the Arduino sketch but i always get,

(\Arduino\libraries\jm_LiquidCrystal_I2C\I2CIO.cpp:29:26: fatal error: jm_Scheduler.h: No such file or directory

#include <jm_Scheduler.h>)

i already added the scheduler library but still the same error. Someone has the same problem??


1 year ago

hey very nice tutorial... i would like to do this tut...

but why are you using a arduinio instead of the pi to controll the led?

also i have one question about the switcher?
do the switcher changes the sources automatically?

example: if u turn on ps4 the switcher switches the hdmi input
automatically to ps4 and also the ambilight switches automatically to
ps4? also could you explain the 5v board u created a little bit more? what is it for exactly?


2 years ago

how to connect the led strip to Arduino ?

Where is this guide, I do not see :-(


2 years ago

Hi. I've been looking at getting the parts together to do this but my sources would primarily be 4K (some HDR, too). I'm assuming all I would need to do it split the signal from my AV receiver and downscale to 1080p the side that is passed to the HDMI2AV. Is that correct?

Also, if I were to use 144 LED/m strips it would just be a case of a large PSU and correct config?