Cyril B. Posted December 27, 2005 Report Share Posted December 27, 2005 I'm new to electronics and i'm trying to experiment on my new project. Here's what i am trying to do: I want to turn on leds one by one using a PIC16F84A programed by the following program: 'Binary progression counting'Initialize variablesSymbol TRISB=134 'Assign TRISB port to 134Symbol TRISB= 6 'Asing the variable portB the decimal value 6'Initialize Port(s)Poke TRISB, 0 'Set port B pins to outputloop:B0= 1 'Set variable to 1 to startB1= 0 'Set variable to 0Poke PortB, B0 'Place B0 value at port to light ledsPause 250For B2= 0 to 6B1= B0 * 2 'Calculate next binary progressiv numberB0 = B1 'Set B0 to new valuePoke PortB, B0 'Place new value at port to light ledsPouse 250 Next B2 'Next loop valueGoto loop I have decided to use 3 button cells (Bat2-bat9) for every led each 1.5V. I guess leds will shine forever. Since this is my first project i'd like some advices. What if switched the 4066 with a 4016? Will it work????http://www.geocities.com/micogjergji/74HCT4066.pdfhttp://www.geocities.com/micogjergji/mmc4016.pdfhttp://www.geocities.com/micogjergji/shume.tif Quote Link to comment Share on other sites More sharing options...
gogo2520 Posted December 27, 2005 Report Share Posted December 27, 2005 Welcomeah a few things I noticed wrong. First use a 10K resistor for pin 4(MCLR) Then I was wondering why so many battires? You would only need one 9 Volt. Not all the leds will be on at once. Also you don't need the 4066's the pic will do all the work. I have a good web site tutorial link for you.http://www.mikroelektronika.co.yu/english/product/books/PICbook/picbook.htm I use asm and not sure if the code you are using is C or Basic. Have fun gogo Quote Link to comment Share on other sites More sharing options...
Cyril B. Posted December 27, 2005 Author Report Share Posted December 27, 2005 Thank you gogo2520Just to clarify a few things.I can get the three batteries+leds for thirty cent each in an assembled package.They are inside some lighters. Thats why i planned to make it that way.I found the code in a book and it is in PicBasic.Not very keen on asm.Any other idea or advice? Quote Link to comment Share on other sites More sharing options...
jstevenperry Posted December 27, 2005 Report Share Posted December 27, 2005 I'm with gogo2520 on this one. You should only need one battery to power the 7805 regulator, which will provide a steady 5V to your PIC. The output i/o pins on the PIC will provide the necessary voltage to drive the LEDs, right? Just make sure to put an appropriately sized resistor in series with each LED to make sure not to overdrive them (based on whatever the current coming out of the pIC is). Quote Link to comment Share on other sites More sharing options...
audioguru Posted December 27, 2005 Report Share Posted December 27, 2005 A 6V battery will drop to 4V near the end of its life.A 7805 regulator won't work from a 6V battery anyway. It needs a minimum input of about 7V. A low-dropout regulator like an LM2931A-5.0 needs a minimum input of 5.5V to regulate well. Its Z package is like a little transistor and I use it for all my 9V battery powered projects where the battery voltage drops to 6V near the end of its life. Quote Link to comment Share on other sites More sharing options...
jstevenperry Posted December 27, 2005 Report Share Posted December 27, 2005 I figured the 6-8V running into the 7805 in the picture should be more towards 8V than 6V :->. I've not worked with the LM2931. The most common type of +5VDC regulator I've seen is the 7805 (276-1770 from Radio Shack). But, like you said, the 7805 won't work with less than 7VDC input. The assumption I was working off of for my comments was based on gogo2520's comment about using a 9V battery as the power source.--steve Quote Link to comment Share on other sites More sharing options...
EdwardM Posted December 27, 2005 Report Share Posted December 27, 2005 Hi Allrelative to 7805's and such like - by the time a fresh 9v battery drops below the voltage necessary to sustain a 5v output, you will be long since bored by a single LED flashing around a loop and probably moved on to several (hundred?) in sequence.Belated Merry ChristmasEd Quote Link to comment Share on other sites More sharing options...
gogo2520 Posted December 28, 2005 Report Share Posted December 28, 2005 Cyril B. Playing with Pic's is fun and addicting. I guess i would want to know were your at as far as having the tools. Like a breadboard, extra parts to play with and so on. Radio Shack dose have some stuff but they are expensive. Also picbasic is ok but I found asm easier to learn and the compiler is free and there is a lot of free help on the web. have fun gogo Quote Link to comment Share on other sites More sharing options...
audioguru Posted December 28, 2005 Report Share Posted December 28, 2005 Hi Ed,I like LEDs and have and had lots of projects with them blinking:1) I made fifteen "Flash Lights" with a single ultra-bright blue, green or white LED blinking 5 times in half a second then a half-second pause. The circuit crams 90mA into the LED and at one time I had all 12 blinking on the ceiling randomly. They light up a car's licence plate from far away.2) My "Mood Lights" slowly fade then brighten ultra-bright red, blue and green LEDs with slightly different frequencies so they make all colours and brightnesses.3) I have a bunch of Plants Watering Watcher-2 gadjets that blink brightly when the plant needs watering and are off or very dim after watering, then their blinking slowly brightens as the plant dries.4) I made ten Ultra-bright Chasers with 10 LEDs each that go around and around a few times then a pause before going again. They have a brightness control because they are really bright.5) Now I have a Sound Level Indicator that uses an LM3915 driving ten LEDs according to Quote Link to comment Share on other sites More sharing options...
ante Posted December 30, 2005 Report Share Posted December 30, 2005 Hi Audioguru, (The LEDing Man) ;)“The circuit crams 90mA into the LED and at one time I had all 12 blinking on the ceiling randomly. They light up a car's licence plate from far away.”Do you really have car license plates hanging from the ceiling? ;DBTW. The "Mood Lights" circuit, is this published in the projects department? Quote Link to comment Share on other sites More sharing options...
audioguru Posted December 30, 2005 Report Share Posted December 30, 2005 Do you really have car license plates hanging from the ceiling?I lost the 1967 licence plates from my very 1st car. My circuits shine on the ceiling then its reflection lights up everything.BTW. The "Mood Lights" circuit, is this published in the projects department?My "mood lights" project isn't posted anywhere. It uses a positive-feedback arrangement to make the voltage ramps reverse-exponential, so they look like their brightness changes slowly very linearly.Circuits that use a linear ramp don't produce a linear brightness change. Quote Link to comment Share on other sites More sharing options...
Cyril B. Posted January 1, 2006 Author Report Share Posted January 1, 2006 Ok Tahnk you guys i'm clear about the power supply.Now one thing i need some help is the 4066. Is it ok the way it is arranged.What do you tell me about the code? Will it work? Can anybody help with the .hex.Does anybody know any free compiler in PicBasic. gogo2520 you're right about getting addicting. I live in Albania and hardly found the Pic. Also decided to change the subject. Just to clarify any of you.One last thing is anybody who lives in Albania? Just to help each other. Quote Link to comment Share on other sites More sharing options...
EdwardM Posted January 1, 2006 Report Share Posted January 1, 2006 Hi Audiogurusorry, I just had to say it...You're the LEaDing LIGHTHappy New YearEd Quote Link to comment Share on other sites More sharing options...
audioguru Posted January 1, 2006 Report Share Posted January 1, 2006 Now one thing i need some help is the 4066. Is it ok the way it is arranged.It isn't designed to pass current like for your LEDs.Its input and output must be referenced to its supply voltage (your LEDs and their batteries are floating) and if the batteries for the LEDs are still connected when its power is shut off it will latch.When passing power it works best with certain pins as inputs: 2, 3, 9 and 10.With a 4.5V battery for 1.7V LEDs then the current will be about 35mA and blow the 4066's and LEDs without current-limiting resistors. Quote Link to comment Share on other sites More sharing options...
audioguru Posted January 1, 2006 Report Share Posted January 1, 2006 Hi Audiogurusorry, I just had to say it...You're the LEaDing LIGHTHappy New YearEdThanks, Ed.Happy New Year to you too. ;D Quote Link to comment Share on other sites More sharing options...
Cyril B. Posted January 2, 2006 Author Report Share Posted January 2, 2006 So audioguru what changes do you sugest me? Quote Link to comment Share on other sites More sharing options...
audioguru Posted January 2, 2006 Report Share Posted January 2, 2006 Hi Cyril,I suggest using the pic's outputs to drive each LED directly, through 240 ohm current-limiting resistors. The LED current will be typically 10mA which would quickly kill little button cells.I suggest using a low-dropout regulator like an LM2931AZ-5.0 which still regulates with a supply voltage of 5.4V.I suggest using at least a 7.5V battery, that will quickly drop to 6V then slowly drop more as it is used. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.