Hello again my fellow readers. Today I present you an older project of mine, the LED coffee table.
The most difficult part was building the table itself and putting all the leds manually in their place.
The schematic and working principle is really simple. It would be very impractical to connect each led by itself, we would need 64 pins from the microcontroller. A better way to do this is by making a matrix, like in the picture below.
We now only need 16 pins, which is easy to manage. The problem in this configuration is that we cannot light up 2 or more specific LEDs without turning on some that we don’t want. If we turn on led[2,2] and led[3,3] we will also light up led[3,4] and led[4,3]. To do this, we only light up one row at a time very fast, so the human eye cannot see. This is how modern display works. In this project, we first ground the first row, turn on the led we want, then go to the next row, until the 8th, then repeat.
For this project I chose to use the very popular ATMEGA328, but we won’t hook up the matrix directly, we will use a shift register. Shift registers are really smart things, u send bits to them, either 1 or 0, which will turn on or off pins of the shift registers. For example if we send 00000001 it will ground every pin, except the last one, who will be VCC (usually 5v). I won’t go into further detail, you can read about them on wikipedia. Below is the schematic I used.
ATTENTION! I need to make one small remark. In my design, I also hooked the shift register outputs to transistors, and then to LEDs, because they cannot sink a lot of current. This design is ok if you want to use a chinese 8×8 led matrix, but for other LEDs please use transistors. (NPN for row / PNP for columns, but u can change this in software).
Here is the arduino sketch (it has some commentary, ask if you need anything, you can change the update speed for example) and this is a html page that generates patterns (credits to this instructable, I just modify it to be 8×8 ), just save it as patterns.h and put it in the same folder as the sketch.
Someone on reddit asked me “The LEDs seem far away from the top.. Is there a reason for that?”.
I didn’t use normal LEDs, but the ones with a flat top which have 100° viewing angle (normal LEDs have 30° if I recall correctly).
Then with a bit of clever math I calculated exactly how deep I will have to put the LEDs for a specific size of my table.
Let’s say we have a square of l = 5cm. The diagonal is l√2 (we need diagonal because we light up even the corners) and then we imagine a triangle like this, in the bottom is the LED (50° because it is only half). We apply tan(50) = 5√2/2 (only half, remember) / X . X is our height or how deep we have to put the LED and in this case is equal to aproximate 4,20.
Below is the video I made and some pictures. Enjoy!
PS. I know this is just very basic information, if you need any help, please ask in the comments below. I will try in the future to edit the code to read the pattern from a SD card or update it via wifi (ESP8266 🙂 )
Merry christmas everyone. I have a present for you.
A sketch with a simple modified webserver for the ESP8266 AT firmware using an arduino. Most credits go to this guy, where i got the basics : http://rayshobby.net/?p=9734 .
What my sketch basically does you might ask?
Well, it first boots up as an AP (access point), you connect to it (just like you connect to your wifi, it should be named something like ESP-???) and access in your browser 192.168.4.1. Here you will see a very simple webpage where you enter the SSID and password of your wifi network, and then it connects to it. After this you can do all sort of things. In this sketch it just shows the same webpage again.
I did this to learn how to use forms with GET method to send and receive data (to fiddle with sensors, use it to turn LEDs on and off, etc).
I won’t post here the full code because i will upload the file and you can also find the simple webserv on rayshobby.
The function “get_data” is very simple and reads what comes out after the /get request. Ignore if it request the favicon.ico (very annoying, chrome sends a request for every refresh of the page – arrrhh), simple display the website if it’s a simple “/get” as if you are accessing the webserver, and if there is a question mark character store the data using the sort_data function. (if you input data and press connect, i will have to add to check if the strings are empty, or if it connects successfuly, this is just a basic sketch)
Please modify the port if u want (but you will have to access the ESP like 192.168.4.1:PORT) and the baud rate. You need to update firmware to be able to change baud rate. I use this one.
I will post a simple tutorial about how to simply turn a led ON or OFF soon but if you understand the code, it should be simple enough. Enjoy!