# Completely new at this

#### elec_mech

Joined Nov 12, 2008
1,500
Tracecom, I can't speak for the OP, but that looks awesome! I have to ask, what are you using between the LEDs and the PICAXE? An LED controller IC, a transistor array like the ULN2804, or a large PICAXE that has enough pins to power each LED individually?

The circuit I just posted would run the red/blue much slower, but if the OP likes the rates you have shown, then a second 555 circuit would definitely be needed.

#### tracecom

Joined Apr 16, 2010
3,944
And here it is.
Quite impressive, although parts of it are over my head.

Diodes D21-D26 are used to protect the pins of the 4017 from reverse voltage.
So, for example D21, D24, and D26 are like a three input OR gate?

PICAXE is relatively inexpensive and I believe the Basic language with it is free - I haven't used PICAXE myself, so I'll have to let Tracecom field that point.
The PICAXE-08M I used is less than $3.00, the programming software is free, and a USB cable is (overpriced) at about$28.00. I built a serial programming cable for (almost) free, but a lot of new PC's don't have serial ports, so I also bought a USB cable.

#### tracecom

Joined Apr 16, 2010
3,944
Tracecom, I can't speak for the OP, but that looks awesome! I have to ask, what are you using between the LEDs and the PICAXE? An LED controller IC, a transistor array like the ULN2804, or a large PICAXE that has enough pins to power each LED individually?

The circuit I just posted would run the red/blue much slower, but if the OP likes the rates you have shown, then a second 555 circuit would definitely be needed.
Thanks. The μC outputs go to a ULN2803A; it's actually a circuit I built to run a stepper motor.

#### tracecom

Joined Apr 16, 2010
3,944
perfect!!!
Thanks.

I will have very limited (or maybe no) internet access for the next 3 to 5 days, but I'll check this thread after that to see how it's going.

Meanwhile, if you are interested in PICAXE programming, there's a web site and a fairly active forum devoted to the subject.

http://www.picaxe.com/

You can actually download the programming software and try things out on the built-in simulator without spending a dime.

#### 32_d3gr33s

Joined Oct 29, 2011
35
And here it is. Still not 100% sure on the MOSFETs, but I'm pretty sure I'm close. I think this could be an excellent example of a project done both with a uC and discrete logic to let others in the future compare and contrast between the two.

The red and blue LEDs are controlled with the CD4017. I've included the timing diagram from the datasheet with a brief description of what is going on. I tied the clock from the 555 to feed the 4017, so the 555 will control the flash rate of all LEDs, effectively flashing them at the same rate although not in the same sequence. If you need the flash rate different between the red/blue LEDs and the yellow/white LEDs, you can add another identical 555 circuit and adjust VR1 differently to get different flash rates.

Diodes D21-D26 are used to protect the pins of the 4017 from reverse voltage.

I'm going to attempt to build this, if time allows tonight, so I can do some tests on finding the right LED resistor values. A 9V battery's voltage is going to drop over time and since we want the battery to last as long as possible, we need to find a happy medium for brightness, voltage drop, etc. If you have room for two 9V batteries, awesome, just be sure they are connected in parallel (9V output), not series (18V output).

I like programming and have used a little assembly, a little C, and a lot of Basic. Personally, I recommend using a PICAXE with Basic. Assembly is free, but the learning curve will take some time and your code will be longer and thus take more time than either C or Basic. C is easier than assembly, but it still has a decent learning curve in my opinion. Basic is by far the easiest and should take you less time to learn and write code than the other two. PICAXE is relatively inexpensive and I believe the Basic language with it is free - I haven't used PICAXE myself, so I'll have to let Tracecom field that point.
That looks amazing! Let us know if you build it how it works. Could you possibly take a quick vid as well? Once you find the right resistor values, would you mind listing all of the components so I could compile a shopping list and get myself an approx cost of the project. Another thing, what LEDs is this set up for? Thanks a ton!

#### 32_d3gr33s

Joined Oct 29, 2011
35
Thanks.

I will have very limited (or maybe no) internet access for the next 3 to 5 days, but I'll check this thread after that to see how it's going.

Meanwhile, if you are interested in PICAXE programming, there's a web site and a fairly active forum devoted to the subject.

http://www.picaxe.com/

You can actually download the programming software and try things out on the built-in simulator without spending a dime.

I'll definetly give that a look. I'd love to be able to do some of my own programming... If I can figure it out!

#### elec_mech

Joined Nov 12, 2008
1,500
So, for example D21, D24, and D26 are like a three input OR gate?
Not quite. The diodes are to protect the pins that are powered down. For example, when pin 1 goes high, it sends not quite 9V to the gate of the MOSFET which turns it on. However, the gate of the MOSFET is also connected to pins 6 and 10. If we don't put diodes on these two pins, then the 9V also goes to them and could burn them out. Same case when pin 6 goes high, pins 1 and 10 need protection, thus there are diodes on each output pin used.

The CD4017 is a counter with 10 decoded outputs. Each output goes high in sequence following a high clock signal. If you where to connect 10 LEDs up to the 4017, one on each of the 10 outputs, and connected a switch to the clock input (pin 15), then each time you pressed the switch, one LED would light and stay lit until you pressed the switch again. Pressing the switch a second time causes the first LED to go off and the second one to come on immediately. You can look at the timing diagram to verify this. Note the outputs on the timing diagram, 0-9, do not correspond to the pin numbers on the 4017.

What I've done is exploited this a bit by using every other output to light the LEDs. So, one output goes high and turns on the LEDs, the next output goes high but is not connected to the LEDs, so they all get turned off. The third output goes high and the LEDs are lit again and so on. So, I "blink" the LEDs labeled 1 in the OP's drawing three times, then I "blink" the LEDs labeled 2 three times.

Perhaps a better visual:

Clock signal received; Output 0 connected to "1" LEDs goes high: LEDs labeled 1 ON, LEDs labeled 2 OFF

Clock signal received; Output 1 not connected to any LEDs: LEDs labeled 1 OFF, LEDs labeled 2 OFF

Clock signal received; Output 2 connected to "1" LEDs goes high: LEDs labeled 1 ON, LEDs labeled 2 OFF

Clock signal received; Output 3 not connected to any LEDs: LEDs labeled 1 OFF, LEDs labeled 2 OFF

Clock signal received; Output 4 connected to "1" LEDs goes high: LEDs labeled 1 ON, LEDs labeled 2 OFF

Clock signal received; Output 5 connected to "2" LEDs: LEDs labeled 1 OFF, LEDs labeled 2 ON

Clock signal received; Output 6 not connected to any LEDs: LEDs labeled 1 OFF, LEDs labeled 2 OFF

Clock signal received; Output 7 connected to "2" LEDs: LEDs labeled 1 OFF, LEDs labeled 2 ON

Clock signal received; Output 8 not connected to any LEDs: LEDs labeled 1 OFF, LEDs labeled 2 OFF

Clock signal received; Output 9 connected to "2" LEDs: LEDs labeled 1 OFF, LEDs labeled 2 ON

Begin back at Output 1 on next clock cycle.

Thanks. The μC outputs go to a ULN2803A; it's actually a circuit I built to run a stepper motor.
Awesome, thank you. If I could just find a MOSFET array now to limit parts count, board space, and voltage loss, we'd be set.

#### ke5nnt

Joined Mar 1, 2009
384
I learned about microcontrollers and the assembly language using This Book. It pretty much teaches you everything about the architecture of microchip MCUs and how they work. Goes through data sheet stuff and is a beginners guide to assembly language. One of the advantages of learning assembly is that, if you use/want to use microchip MCUs, the datasheets of those things give all their examples in assembly language. Any questions I had while learning assembly and reading that book were answered here at AAC.

C programming I'm learning from This Book. It's not quite as in-depth as the book above, but it has been useful. Between this book, AAC, and the rest of the internet, learning C has been relatively easy and rewarding. I've found that knowing assembly beforehand can be a leg-up, but isn't necessary. Both languages seem to be one of those things that if you don't use it regularly, you start to forget things, but quick refreshers get you back up and running.

It's all about preference. There are many languages out there, and several kinds of chips that support the various languages. Everyone will have their own opinion of what you should learn and which is the best. Just up to you. Good luck!

#### 32_d3gr33s

Joined Oct 29, 2011
35
just a quick question... I have a couple of these flashers. there was a button that you press, and it goes through its cycle, then shuts off. What would be the easiest way to make this continually repeat until i disconnect the power? Thanks!

#### elec_mech

Joined Nov 12, 2008
1,500
I assume that's a paperclip being used to short the two contacts?

If yes, try holding the paperclip across the contacts continuously and see if the circuit keeps going. If yes, then you just need to solder in a jumper wire across the two contacts.

If not, the controller is probably programmed to light the LEDs when a clock cycle is detected (transistion from high-to-low or vice-versa). Only way around that is to connect a clock generator to the pins so that it is constantly receiving a high and low signal (simulating a button being constantly pressed and released).

#### tylernt

Joined Nov 2, 2011
2
I guess if some one could point me in the direction of how to learn how to make a pcb and an approx cost of materials needed to do it,
I've had good success using perfboard for small and simple projects. I like the kind with round or square copper pads on the solder side. Connections between components can be made by deliberately bridging adjacent pads with extra solder, or by using the pieces of resistor and capacitor leads that you cut off because they were too long. If you have a spare Cat5 Ethernet network cable or phone cord, you can hack it up and harvest the 26ga wires inside for longer traces.

If you are going surface-mount, you can also buy SMT grid "proto boards" with the same idea on a finer pitch, and without the through-holes.

#### 32_d3gr33s

Joined Oct 29, 2011
35
I've had good success using perfboard for small and simple projects. I like the kind with round or square copper pads on the solder side. Connections between components can be made by deliberately bridging adjacent pads with extra solder, or by using the pieces of resistor and capacitor leads that you cut off because they were too long. If you have a spare Cat5 Ethernet network cable or phone cord, you can hack it up and harvest the 26ga wires inside for longer traces.

If you are going surface-mount, you can also buy SMT grid "proto boards" with the same idea on a finer pitch, and without the through-holes.
Thanks for the input!

Anyone have any updates on this? I get paid today and would love to go shopping for some parts for this so i could get started on it tomorrow!

#### elec_mech

Joined Nov 12, 2008
1,500
It's taken me two days to build the discrete logic circuit I proposed, but I did get to power it last night. Unfortunately, the 555 didn't work as I expected, so I used a function generator to give me a clock pulse to play with until I get the 555 circuit resolved. The red/blue lights only blink twice before changing colors, so I've got to troubleshoot that tonight.

Are you leaning toward a discrete logic solution (more parts and space) or a microcontroller solution (less parts, learn to program)?

I can help you with the former once I've got the circuit working, Tracecom with the latter as he's build a working model.

In either case, you'll want LEDs. Will thru-hole work or are you going to opt for surface mount? 3mm round LEDs (thru-hole) would work well and be pretty darn bright. Tracecom is using 5mm in his video, so 3mm would be smaller still.

If 3mm is okay, the best price I've found them in bulk (as you mentioned making several of these for gifts) is here: http://www.ledshoppe.com/led3mm.htm.

These are cheap, shipped from China or thereabouts and don't be surpirsed if a few out of 100 don't work. But for 12 cents or less an LED plus free shipping, you can't beat them. I'm using the red and blue LEDs from them in my circuit and hope to post a video soon too (if I can figure out how to upload it). They don't sell much else electronics-wise, so if you're inching to buy something, you can go ahead and get the LEDs from them if they're want you want.

If you opt for SMT or another style from another supplier, I'd wait until you have a finished schematic with a complete parts list. It is very tempting to go and buy a handful of things for a project immediately, but you're better off waiting until your design is fleshed out before ordering anything, otherwise you'll end up paying for shipping (or gas) multiple times before you have everything you need.

#### 32_d3gr33s

Joined Oct 29, 2011
35
It's taken me two days to build the discrete logic circuit I proposed, but I did get to power it last night. Unfortunately, the 555 didn't work as I expected, so I used a function generator to give me a clock pulse to play with until I get the 555 circuit resolved. The red/blue lights only blink twice before changing colors, so I've got to troubleshoot that tonight.
Thats fine... Take your time. I was just hoping it would work good first try. Things are never that easy though!

Are you leaning toward a discrete logic solution (more parts and space) or a microcontroller solution (less parts, learn to program)?

I can help you with the former once I've got the circuit working, Tracecom with the latter as he's build a working model.
I actually would love to learn how to program a microcontroller, but i think that route will be put on the back burner. Id rather have a few extra parts on my board, and be able to do it without learning a whole separate language (so to speak lol)

In either case, you'll want LEDs. Will thru-hole work or are you going to opt for surface mount? 3mm round LEDs (thru-hole) would work well and be pretty darn bright. Tracecom is using 5mm in his video, so 3mm would be smaller still.

If 3mm is okay, the best price I've found them in bulk (as you mentioned making several of these for gifts) is here: http://www.ledshoppe.com/led3mm.htm.

These are cheap, shipped from China or thereabouts and don't be surpirsed if a few out of 100 don't work. But for 12 cents or less an LED plus free shipping, you can't beat them. I'm using the red and blue LEDs from them in my circuit and hope to post a video soon too (if I can figure out how to upload it). They don't sell much else electronics-wise, so if you're inching to buy something, you can go ahead and get the LEDs from them if they're want you want.
Thats a good deal. Ill probably pick some of those up either way, but the should probably work just fine for this project.

The current lightbar that i have uses 1.8mm LEDs, (which are alright, but not very visible from a distance) 3mm Should be more than enough for this!

If you opt for SMT or another style from another supplier, I'd wait until you have a finished schematic with a complete parts list. It is very tempting to go and buy a handful of things for a project immediately, but you're better off waiting until your design is fleshed out before ordering anything, otherwise you'll end up paying for shipping (or gas) multiple times before you have everything you need.
I know how that goes. I was planning on running to the store anyway though. I want to pick up some stuff that i needed anyway, and thought i'd get anything else i could.
Any parts that i would be ok to get and not have to worry about not using other than the leds? I plan on picking up a bread board/ solder-less board (whatever they are called) that way i can do some of my own tinkering anyway!

Thanks again for all the help, and look forward to the end result!

#### 32_d3gr33s

Joined Oct 29, 2011
35

#### elec_mech

Joined Nov 12, 2008
1,500
I was just hoping it would work good first try. Things are never that easy though!
So very, very true.

Any parts that i would be ok to get and not have to worry about not using other than the leds?
Well, if you don't already have them, a solderless breadboard is always good to have if you plan to tinker and perhaps get more into electronics. I'd wait on the protoboard just because we don't yet know what the final circuit will look like and thus know how big a board you'll need.

Unless I happen to completely redesign it (unlikely), you can go ahead and get the following:
1N4148 or 1N914 or 1N918 diodes
10kΩ resistors, 1/4W
An assorted pack of resistor values if you'd like some to tinker with
0.1uF ceramic or mylar capacitors
1.0uF electrolytic capacitors (don't need many, 1-2 is fine)
555 Timer IC
CD4017 IC
N-Ch MOSFET, rated for 150mA or higher in a TO-92 package such as a BS170
9V battery snaps

i was just browsing, and this seems to be a little cheaper than your link...
http://www.ebay.com/itm/5value-500pc...item484274aef4
i see the mcd rating is a little lower. how much of a difference in brightness would that be? Those would still be quite a bit brighter than the 1.8 mm LEDs on my other lightbar right?
Okay, with LEDs a couple points should be noted:
1) mcd ratings have to be taken with respect to viewing angle. A mcd of 1000 and viewing angle of 25° is going to "appear" brigher than an mcd of 3000 and a viewing angle of 90°.
2) Diffused LEDs (those whose body is colored or is anything short of clear) are used as indicators, meaning they generally go onto displays people will look right at, so they aren't bright - as an example, your alarm clock digits are diffused - you don't want to go blind when you check the time.

That said, the LEDs you found have a similar viewing angle to the ones I mentioned (25° vs 30°) and the mcd ratings still seem plenty bright. I'm a little leary of the pictures as most of those are diffused - the supplier states the pictures may not match the product but I can't see why they wouldn't post pictures of the actual product. The price is certainly tempting. You'll pay 20 just for the blue and white LEDs at ledshoppe, so it's probably worth a shot to buy the ones you found. If the red and yellow ones are diffused, you can always use them for another project. Thread Starter #### 32_d3gr33s Joined Oct 29, 2011 35 Unless I happen to completely redesign it (unlikely), you can go ahead and get the following: 1N4148 or 1N914 or 1N918 diodes 10kΩ resistors, 1/4W An assorted pack of resistor values if you'd like some to tinker with 0.1uF ceramic or mylar capacitors 1.0uF electrolytic capacitors (don't need many, 1-2 is fine) 555 Timer IC CD4017 IC N-Ch MOSFET, rated for 150mA or higher in a TO-92 package such as a BS170 9V battery snaps So I was just looking on radio shack's website to see how much i was looking at price wise. I noticed i couldnt find a couple things on the list on their website. I figured i'd check prices on mouser.com and im looking at about 1/10th the price. Just a couple questions though... for the capacitors, what voltage and tolerance do i want? for the mosfet all i seem to find is 60v 500ma is that ok? I was looking at what you have drawn up, and there is something called vr1 500k. what is that? thanks again! I think thats all i have as far as questions right now... #### elec_mech Joined Nov 12, 2008 1,500 Although I like RadioShack and even used to work there, it will be much cheaper to purchase the parts from an electronics parts supplier like Mouser, Digikey, etc. Since you'll be using 9V, most MOSFETs should work. And yes, a high current and voltage rating is fine. At a minimum, the MOSFET should be rated to handle about 20V or more (just to be safe) and 150mA or more. 60V and 500mA is great. Just note that many of the thru-hole versions come in a TO-220 package. I recommend a TO-92 package since this will take up less space on your board. The VR1 stands for variable resistor otherwise known as a potentiometer or simply pot. I used a 500kΩ, 10-turn potentiometer. A 10-turn pot will give you finer tuning of your flash rate. Okay, I found a couple of snafus with my circuit design and corrected them last night. I even managed to get a very poor quality video shot last night and posted it here: http://youtu.be/RQdXOdgp0Es. For the first 30 seconds, all LEDs are connected to the 555 clock which is set to a slow rate. After 30 seconds, I connected the red/blue LEDs to a function generator (simulating a second 555 circuit with a faster rate if you will) and played with different rates for the remaining minute of video. The white/yellow LEDs are connected to the slow 555 for the entire video. Take a look and let me know what you think. It will of course look a lot better on a finished board with the LEDs aligned. I try not to cut leads on parts down for breadboard circuits in case I need the length for something else in the future, hence the circuit does not look nearly as clean as Tracecom's. I did lay out the LEDs in the same pattern and wired to flash as you initially described. So, in a nutshell, the circuit in the video will do what you want but you will probably need to add another 555 circuit so you can control the blink rate of the red/blue and yellow/white LEDs independently. I've also included an updated schematic. Don't hold me to the LED resistor values just yet, I need to play with a 9V battery and see what is the ideal value as the battery loses voltage over time. The values currently given are for a constant 9V source, a battery's voltage will slowly drop with time as current is consumed. We may also need to wire the LEDs a little differently to maximize battery life, but that won't require more parts. #### Attachments • 104 KB Views: 16 Thread Starter #### 32_d3gr33s Joined Oct 29, 2011 35 Since you'll be using 9V, most MOSFETs should work. And yes, a high current and voltage rating is fine. At a minimum, the MOSFET should be rated to handle about 20V or more (just to be safe) and 150mA or more. 60V and 500mA is great. Just note that many of the thru-hole versions come in a TO-220 package. I recommend a TO-92 package since this will take up less space on your board. The ones that i did find were the TO-92 package so thats great. I was just iffy with the voltage because im not too familiar with this stuff just yet. The VR1 stands for variable resistor otherwise known as a potentiometer or simply pot. I used a 500kΩ, 10-turn potentiometer. A 10-turn pot will give you finer tuning of your flash rate. Alright that makes sense. I looked a little, but cant seem to find any 10 turn... all my results come up with are 1 turn, or 3 3/4 turn. The only 10 turn i find are almost120. Not sure what im doing wrong...

Okay, I found a couple of snafus with my circuit design and corrected them last night. I even managed to get a very poor quality video shot last night and posted it here: http://youtu.be/RQdXOdgp0Es.

For the first 30 seconds, all LEDs are connected to the 555 clock which is set to a slow rate. After 30 seconds, I connected the red/blue LEDs to a function generator (simulating a second 555 circuit with a faster rate if you will) and played with different rates for the remaining minute of video. The white/yellow LEDs are connected to the slow 555 for the entire video. Take a look and let me know what you think.
It actually looks really good!! first part is a bit too slow. :35-:42 in the video is PERFECT!! Along with 1:20-End is just as good! The white/yellow is almost exactly hat i had in mind for the speed. Once its all assembled, will we still be able to change the flash rates?

It will of course look a lot better on a finished board with the LEDs aligned. I try not to cut leads on parts down for breadboard circuits in case I need the length for something else in the future, hence the circuit does not look nearly as clean as Tracecom's. I did lay out the LEDs in the same pattern and wired to flash as you initially described.

So, in a nutshell, the circuit in the video will do what you want but you will probably need to add another 555 circuit so you can control the blink rate of the red/blue and yellow/white LEDs independently. I've also included an updated schematic. Don't hold me to the LED resistor values just yet, I need to play with a 9V battery and see what is the ideal value as the battery loses voltage over time. The values currently given are for a constant 9V source, a battery's voltage will slowly drop with time as current is consumed. We may also need to wire the LEDs a little differently to maximize battery life, but that won't require more parts.

Sounds good! Look forward to hearing back!

#### elec_mech

Joined Nov 12, 2008
1,500
The ones that i did find were the TO-92 package so thats great. I was just iffy with the voltage because im not too familiar with this stuff just yet.
No problem. As a general rule, you want your part rated higher than your max expected voltage and current. Your voltage is a 9V battery which might go as high as 10V new, so 20V or higher adds some safety. The biggest current draw will be the LEDs. Currently, the max current draw on any one MOSFET comes from six LEDs wired in three sets of two. If we drive the LEDs at a max of 30mA, this works out to about 90mA pulled across the MOSFET. If we were to wire each LED individually, the draw would be 6 x 30mA = 180mA. So 500mA gives us plenty of room if we need it.

Alright that makes sense. I looked a little, but cant seem to find any 10 turn... all my results come up with are 1 turn, or 3 3/4 turn. The only 10 turn i find are almost $120. Not sure what im doing wrong... Doh! Apparently I'm using 25-turn pots. I found them for as low as$1.30 on Digikey. You can get them cheaper from Electronix Express: http://www.elexp.com/cmp_mpt5.htm - this is where I got mine. You may or may not find the other parts cheaper here too. They are great for buying solderless breadboards, protoboards, and jumper wires for the solderless boards.

It actually looks really good!! first part is a bit too slow. :35-:42 in the video is PERFECT!! Along with 1:20-End is just as good! The white/yellow is almost exactly hat i had in mind for the speed.
Cool beans, I'll figure out what rate that was and test the second 555 circuit to meet it.

Once its all assembled, will we still be able to change the flash rates?
Ah, that is why we are using the potentiometer. If you wanted to save some money and space, we could use the pot to determine what flash rate you want to stick with, measure the resistance across the pot, then replace it with a resistor. Since I assume you'll want to change the flash rate on the fly, I've added the pot. As long as it is in the circuit, you'll be able to change the flash rate on the fly. Now, I've used a square pot with a top adjustment. Since you want a low profile, you might want to use a rectangular pot with a side adjustment. In this way, you could put the pots both on one side or opposite sides of the board so the user can adjust either the red/blue or yellow/white flash rate whenever they want with a small screwdriver. Take a look at these: http://www.elexp.com/cmp_mtt1.htm.

Don't rush to buy the pots just yet - I want to test a few things and I might discover a wider range of adjustment by changing the pot value.