loading

Welcome to my first instructables page. A year ago I got introduced to the wonderful world of Arduino and electronics. I have learned a lot from this site and this seems a great place to show my projects. I hope you find this project entertaining and helpful.

I'm eager to know what you think. Let me know in the comments, please keep in mind I'm a beginner and not a native speaker. All of your comments are welcome ;)

The project

I few months ago my night lamp broke and I was looking for a replacement. Then I thought: why buy one if I can make one! My first intentions was to use an Atmega328 but this project required only a few pins and I wanted the built be a cheap as possible. So I did some research and ended up with an Attiny85.

My self-built night lamp has 3 knobs to choose the desired colour, saturation and brightness. Also there are 3 buttons you can press to select one of your favorite preset colours. These presets are programmable and can be altered as may times you would like. Just pick your desired colour and hold the button down for 3 seconds. I also implemented a fading colour wheel. Hold down button 1 and button 3 to activate this mode. The knob to control the colour can now be used to control the speed of the fading colour wheel. To exit this mode simply press one of the preset buttons or turn one of the knobs.

Watch this video to see the finished project:

Step 1: Get Your Supplies

It's time to get your supplies! The most items on the list I got from eBay or Amazon. These items are widely available so I recon it won't be a problem to find them.


Items

  • ATTINY85 (20PU)
  • Proto-Board
  • Single Addressable LED 8mm {PL9823 or WS28xx-series} [60mA, 5V] (8x)
  • Ceramic capacitor 100pF [104] (8x)
  • Electrolytic capacitor 47uF (3x)
  • Potentiometer 10K (3x)
  • Knobs (3x)
  • Silicon diode (3x)
  • Push button with green led [12V] (3x)
  • Resistor 220 ohm (4x)
  • Resistor 10K ohm (3x)
  • On/off switch
  • IC socket (8 pins)
  • Rubber foot (4x)
  • Power supply [5V, 500mA]
  • Pinewood bar (1000mm X 100mm X 12mm)
  • Opal acrylic glass (500mm x 250mm x 5mm)
  • Wood glue
  • 4 nails


About the LEDs (PL9823)

For this project I used a cheap version of the Adafruit Neopixel. I got them on eBay, 100pcs for 18 euro. They are similar to the ws28xx-series LEDs and only need one data-pin to control them. They also work with the popular FastLed library and are easy to control.


About ATTINY85

The Attiny85 is a low power 8-bit Atmel microcontroller and can be programmed via the Arduino IDE. I chose this microcontroller because it's small and has all the necessary pins for this project. As we only need 3 AnalogIn-pins and 2 digitalOut-pins.

Step 2: Make the Base

Time to show off your wood working skills!

Cut the wood - For this built I used regular pinewood (vurenhout in Dutch). I cut the pinewood bar into 4 pieces each with a height of 100mm. The front and the back will have a length of 220mm and the sides 196mm because I want to make a square and the wood has a thickness of 12mm.

Drill holes - I drilled 10 holes in the frontplate and 6 in the back plate (for the 4 nails, power cable and switch). Make sure the holes for the buttons have clean edges because otherwise the end result will look sloppy. The holes for the potentiometers can be a little rough because they will be covered by the knobs.

Make indentations - I made a few indentations for de potentiometers and the pushbuttons because the wood I chose was to think. I used a rotary tool and lots of patience. You can skip this step if you have chosen the correct thickness (depends on the size of the buttons and potentiometer).

Make a hole for the switch - Use a file to make a square hole for the power switch. Don't forget the hole for the power cable.

Pre-drill holes for nails - I used long nails and some wood glue to hold the pieces together. I therefore drilled 8 holes (4 in each of the sides). Make sure you drill perfectly straight otherwise the nails will come out through the side panels.

Apply some wood glue and insert the nails - Apply the glue before you insert the nails.

Make a standing edge - Use a file or a rotary tool to make a standing edge. This wil prevent the cover form sliding off.

Step 3: Make the Cover

Prepare to get hot and sticky

Cut the acrylic - Cut the acrylic glass to a length of 500mm and a width of 220mm. Make sure you have a straight cut.

Bend the acrylic - Use a heat gun or an oven to heat the piece so it can be bend. I used tinfoil to protect the areas I don't want to bend. Again: make sure you have a straight and even angle.

Cut the side pieces - Cut the side pieces from the remaining acrylic. I purposely cut them too wide and sanded them down later to ensure a good fit.

Glue it together - I used hot glue to secure the pieces but there are better kinds of glue you can use for this task (if you demand a stronger bond)

(Optional) Sand down the acrylic - I sanded down the acrylic to give it a softer touch and less glossy finish.

Step 4: Schematics

The built is pretty easy but there is a little trick. The lamp has 6 inputs (3 knobs and 3 buttons) but the Attiny only has 3 analog input pins. To solve this problem the first potentiometer and the first button share an analog pin, this applies also to the second and third potentiometer and button.

When a button is pressed the current flows without much resistance to the analog pin, and we get a reading of 1024 (i.e. 5V). When the button is not pressed the current flows through the potentiometer. This current has to travel through a diode (which has a voltage drop) first before it can enter the analog pin. Therefore the maximum reading we can get is determined by the diode voltage drop.

The maximum reading I got was 910. So now we know when the value of the first pin exceeds 915 that a button is pressed, a lower number indicates otherwise.

Further we use a 10K ohm pull-down resistor to debounce the button press and a electrolytic capacitor for the potentiometer.

We use a 100pF ceramic capacitor for the LEDs and a 220 ohm resistor to protect the data pin from voltage spikes. And a four 220 ohm resistors for the push button LEDs to limit the current.

Note: The 9V depicted is not representative, we use a 5V power source

Step 5: Solder

Now comes the tricky part: the soldering.

Pay close attention to the positive an negative pins, the LEDs are not protected agains reverse voltage. And make sure the buttons are well placed and they have a snug fit into the holes we drilled in the front plate.

Step 6: The Code

I did my best to describe the code as well as I could. This is my first real coding project and I think there is room for some improvements, I'm open for suggestions.

If you want to use this code for your Arduino Uno you will have to change the pins

Step 7: Program the ATTINY85

I won't go in to much detail here. There are a lot of great tutorials how you can program an attiny85. I linked in 2 sources below. I will briefly describe the steps you will have to take

1. Download the attiny library at github:

https://github.com/damellis/attiny/ar...

2. Upload the ArduinoISP file to the arduino

3. Connect the arduino with the attiny:

Arduino pin Attiny Pin

  • 5V -> VCC
  • GND -> GND
  • Pin 10 -> Reset
  • Pin 11 -> IO 0 / digital1 / 5
  • Pin 12 -> IO 1 / digital2 / 6
  • Pin 13 -> IO 2 / analog1/ 7

Don't forget to put a 10uF capacitor between the ground and the reset of the arduino

4. Select ArduinoISP as programmer and select Attiny 1Mhz or 8Mhz board

5. Upload your sketch

Helpful sites:

AwesomePCB: https://www.instructables.com/id/How-to-Program-ATt...

codebender_cc: https://www.instructables.com/id/How-to-program-the...

Step 8: Put It All Together

Now comes the fun part, bringing it all together!

- Feed the power cable through the hole and solder it to the proto-board

- Screw the buttons in the front panel

- Insert the programmed Attiny85 in its socket

- Place the knobs

- Screw on some rubber feet

- Optional: To increase the weight I used a few heavy bolts and hot glued them to the base

- Place the cover, plug it in and enjoy

Step 9: Future Improvements

In the next version I would like to implement:

1. More LEDs - I would use at least 16 LEDs and a bigger power supply, I find 8 LEDs a bit too weak.

2. Paint the base

3. Use memory - to store the new presets possible with a EEPROM IC. (now if you unplug the lamp, it will forget your newly added presets)

4. Find a way to individually address the push button LEDs - so I can display which program is currently active

<p>Hi, I am going to do this project for a college test and I would appreciate to have some of my doubts answered, note in mind that I am still and begginer with arduinos so I don't know much about them at the moment.</p><p>1: What were the cables that you used to connect the eletronic components with the protoboard? Were they just regular Jumper cables?</p><p>2: The input of the power suppy to the lamp is made via a MicroUSB adapter?</p><p>3: Is It possible to make this project with a regular protoboard and a Arduino Uno?</p>
Hi, Thanks for your comment. To anwser your questions: <br>1: I used regular cables I got with my arduino starters kit. They are called dupont cables. <br>2: I used an old phone charger (Nokia I think, that old one that every one had in my days). Important is that your power supply is 5v (so you could use a microUSB charger) and that the current draw doesn't exceed the maximum of your power supply. So if your leds draw 1.0A, make sure your power supply can supply at least 1A (1.5 is a better choice just to be sure).<br>3: It is possible to make this project with a arduino uno instead of an attiny. Just change the data_pin (top of the code) to your desired (arduino uno) output data pin. Also change the &quot;0&quot; (zero) at the end of the setupLoop, to de desired data output pin.<br><br>I hope I explained it well enough. If not, just aks!<br><br><br>Good luck with your college test! Keep thinkering!
<p>Great project :-D</p>
<p>hi mate, thank you for sharing idea!</p><p>i usually use the RGB led that was part of my arduino starter kit, and it really looks like the pl9823 but i'm not sure they are the same because i must set the color value on the relative pin and the last pin on the ground to have the correct color; but the color blending is really awful.</p><p>Do you know if pl9823 can be used also as a simple rgb led ?</p>
<p>They look the same but they are different. You can't use the PL9823 as a normal RGB LED (with a common anode or cathode). The PL9823 has a chip inside. The red, green and blue LEDs are connected to this integrated chip. </p>
<p>can we make one using arduino?</p>
Of course. I first used the arduino board (atmega328) for prototyping and debugging. Just change the DATAPIN to your desired output pin.
<p>I am very impressed with your instructable. I enjoy projects that use the ATTiny as they are so small and yet can do so many wonderful things. I think you were very creative with the dual function of the analog pins...Bravo! I know I will breadboard this circuit in the near future.</p><p>Thank you so much for sharing,</p><p>Build_it_Bob </p>
<p>Thank you (all) very much. It's great to hear so many people enjoy my project.</p><p>Don't forget to vote for the contest if you liked it. Thank you</p>
<p>Hello again, I just read through your code and I like your style. There is so much that I can learn from it as well.</p><p>Thank you again,</p><p>Bob </p>
<p>Read step 4 carefully.</p><p>When you don't use a diode in this configuration (linked with a button press) you get a unstable read at your Attiny AnalogIn pin. Also I had to figure out a way how to connect 2 inputs on one pin. The diode reduces the voltage, so the maximum reading you get from the potentiometer is less than the voltage from the button press. If I wouldn't use a diode and I would turn the potentiometer to its maximum setting, the reading would be 1024. I wouldn't be able to tell the difference between a maximum reading of the potentiometer and a button press.</p><p>I hope this helps. Don't hesitate if you have more questions.</p>
<p>Hi! Great project</p><p>Why the diodes with the potentiometer? </p>
<p>Great,</p><p>I am going to build one.</p><p>But can You give u's a source for the * </p><p>Push button with green led [20mA Vf=3.0] (3x)</p><p>Bedankt en Ik kijk uit naar het vervolg.</p><p>efbe</p>
<p><strong>Blue Circle Push Button Led Switch 10mm: </strong><a href="http://www.ebay.com/itm/5pcs-Blue-Led-Dia-10mm-Cap-CIRCLE-12V-Momentary-Tact-Push-Button-Switch-/332056777673?hash=item4d502053c9:g:RsIAAOxyirJSHGvo" rel="nofollow">http://www.ebay.com/itm/5pcs-Blue-Led-Dia-10mm-Cap...</a></p><p>Couldn't find the green ones. </p><p>Good luck building one. I'm eager to see yours. Let us know when you have finished it. </p>
<p>Unfortunately my source doesn't sell them anymore. And thanks to you I spotted a mistake: the push button leds are rated voor 12V(50mA) not for 5V, but they just work fine.</p><p>Just search for ''push button switch led 10mm'' on eBay. </p>
<p>Great</p>
<p>wonderful , feeling!</p>
<p>Beautiful!</p>
<p>Nicely done. </p>
<p>That's a clever way to connect an potentiometer and a button the the same I/O, very useful technique for microcontrollers with limited pins. I might borrow that for af future project :D</p><p>The attiny85 does have a 512 byte of internal EEPROM, so there's no need to add an additional IC, just a few lines of code ;)</p>
<p>Thanks!</p><p>That's true, I totally forgot the internal EEPROM. Thanks for reminding me. </p>
<p>great keep it up</p>
<p>This is great! Very well done, all around :)</p>

About This Instructable

19,425views

315favorites

License:

More by Svinska013:Programmable RGB Mood Light - Attiny85 
Add instructable to: