Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

voltage divider

Not open for further replies.


Well-Known Member
How do i calculate 2 resistors value for dividing voltage?

Like i have a 3.3v supply but need it to be 2.5v-3v.

Whats the formula or how would i do this in ohms law?
If you're using it as a voltage reference you'll find it may vary under load. A simple shunt regulator like the common TL431 is a very good voltage reference.

Else here's a voltage / resistor divider calculator link.
**broken link removed**

**broken link removed**
The ratio of R2/(R1+R2).
Input goes to R1, output comes from junction of R1 and R2.
R2 also goes to ground. Input is ground to R1.
Output is ACROSS R2, to gnd.
Multiply the input voltage by this ratio.

If the load, which attatches to R1-R2 junction is known in Ohms, include it with R2, say R2'=the parallel combo of R2 and the load.
The ratio is then R2'÷(R1+R2'), multiply this loaded divider by the input voltage.

You can choose the lowest value of R's that your source can furnish current to, reducing load resistor effect. Since the R2 is parallel with the load, the smaller R2 the closer the combo is to R2.
A 78L05 or a low power LDO would be better. That battery only has 40 mah. It won't last long!
I might just take 2-3 AA batteries .. rechargable with a nice 2500mAH.. which would mean this would last about 125 hours on 1 full charge.

Thats about 1 charge a month... How many times can one charge a battery before it dies?
Last edited:
Yes, two AA cells will last much linger than that tiny 12V battery.

If I remember rightly a NiMH cell can survive 500 cycles after which its capacity is reduced to 80% of the original.

Also, if a 12v battery is used to power a 5v device with a zener or other
linear regulator there is a lot of battery power wasted as heat. If a
switching regulator was used instead, two times the run time could be had.
Instead of (say) 1 hour, it would run 2 hours.
This is only true when the input voltage (12v) is way above the output (5v).
With three AA cells, that's only 4.5v and you could run the PIC directly
without any regulator (5v PICs) unless you need to do voltage measuring AD
converts which then you also need a stable voltage reference.
If you are doing ratiometric converts you dont need a voltage reference though.

One additional little note:
If you use the sleep mode you can wake the chip up once in a while to do
a measurement. The battery can last for years this way.
By the way its for a small sound toy i made my son. it has 5 buttons all to play different tones. I chose the ones he like the most..

Im going to get a little case made for it also.

He first heard the noise when i was testing the buzzer on my LPC and tried to rob me of it heh

So i decided to make the same thing with my PIC chips and he like it but im not going to hand him a PCB with some batteries lol hence the case. i will test out :

Polycase - Plastic Electronic Enclosures

site and see if their service is good.
LDO (low dropout voltage) regulators are ideal for battery powered equipment where every volt counts. If the difference between the input (battery) and output (load) voltage is greater than 0.2V, then the regulator will disipate more power. If the I/P to O/P difference is large (ie battery = 12V, load = 3.3V), then the power dissipation will be like a standard 7805. LDO regulators are designed to run on small voltage differences. For a 3 x 1.2V AAA NiCa battery pack that starts at 4V fully charged and drops to 3.5V when discharged, critical circuits need to maintain a nice constant voltage. In this case, the load voltage would be govorned by the regulator at 3.3V while the battery voltage drops to 3.5V (3.3 = 3.5 - 0.2). Heres a 0.2V minimum dropout, 3.3V @ 100mA LDO regulator to look at.

Regs Q


  • IC Voltage regulator LDO LE00AB ST.pdf
    1.2 MB · Views: 248
Those are cool! but requires about 3 weeks wait in the mail heh.

Version 2 of this sounder would incorporate it. I will place a order tomorrow for the 3.3v version (LE33ABZ (1% version))

For now since its somewhat built and i can use a small RS(Radioshack) case i will not use it.

Its running perfect on 2 AA batteries tho. I might just use 3 AA alone and sleep mode.

Im off to print out some pages on the sleep mode of PIC micros (im using a 18F1320) at my job since we have a laser printer (fast) and boss says its ok for me to use it whenever i need.

Thats where i print my PCBs now :D Thanks guys!!!


Can someone please post some tips on sleep mode and how to enable it and use it..
Also i have a new button on RA0 can i use this to wake up?
cool.... How can i put a pic into sleep mode? Never tried.. also how do i wake it up?

Hi again,

Take a look at the data sheet for the PIC part you are using.
Look for the description of the 'sleep' instruction. That should
tell you most of what you need to know to use this. It's not
hard at all really.
I think you can have it wake on io change too, so you might be able
to set it up so that it doesnt do anything until a button is pressed,
then it wakes up and does whatever you want it to do (like play a
tone). This is nice because the kiddies cant forget to turn the
device off and run down the batteries as the PIC consumes very
little power in sleep mode.
If not you can wake it every half second or so and read the buttons
with the same power savings.
heh here we go:

#include <p18Cxxx.h>
#include <delays.h>
#pragma config WDT = OFF, LVP = OFF, OSC = INTIO2

#define button1 PORTAbits.RA3
#define button2 PORTBbits.RB2
#define button3 PORTBbits.RB3
#define button4 PORTBbits.RB4
#define button5 PORTBbits.RB5

#define WakeMe PORTBbits.RB0

char pos;
int time;
void PlayTone(char num);
void high_ISR (void) ;
void high_interrupt (void);
void NightTime(void);

#pragma code high_vector = 0x08
void high_interrupt (void){
_asm goto high_ISR _endasm
#pragma code

#pragma interrupt high_ISR
void high_ISR (void) {
    INTCONbits.INT0IF = 0;
    INTCONbits.RBIF = 0;
    LATAbits.LATA0 = 1;    

void main(void){
 int k,j,i;
    OSCCON = 0x72;              //8MHz clock
    while(!OSCCONbits.IOFS);    //Wait for OSC to become stable

    pos = 0;

    ADCON1 = 0xFF;
    TRISB = 0xFF;
    TRISA = 0x00;

    TRISBbits.TRISB1 = 0;
    TRISAbits.TRISA3 = 1;

    LATBbits.LATB1 = 0;

    INTCON  = 0b10010000;
    INTCON2 = 0b11110000;
    INTCON3 = 0x00;
    RCON    = 0b10000000;

    LATAbits.LATA0 = 1;
        if (button1)
        else if (button2)
        else if (button3)
        else if (button4)
        else if (button5)


        if(time == 20){

void NightTime(void){
    LATAbits.LATA0 = 0;         //Turn off LED
    OSCCONbits.IDLEN = 0;       //Clear he IDLEN and SCS1:SCS0
    OSCCONbits.SCS1 = 0;
    OSCCONbits.SCS0 = 0;
    Sleep();                    //Call Sleep instruction

void PlayTone(char num){
int k,j,i;
int len;
time = 0;
    switch (num){
        case 0:
            len = 100;
        case 1:
            len = 150;
        case 2:
            len = 200;
        case 3:
            len = 250;
        case 4:
            len = 0;
    if(!len) goto skipit;

        LATBbits.LATB1 = 1;
        for (i=len; i>0; i--);
        LATBbits.LATB1 = 0;
        for (i=len; i>0; i--);
    goto doneit;
                LATBbits.LATB1 = 1;
                for (i=k; i; i--);
                LATBbits.LATB1 = 0;
                for (i=k; i; i--);
        pos = 0;
} else {
                LATBbits.LATB1 = 1;
                for (i=k; i; i--);
                LATBbits.LATB1 = 0;
                for (i=k; i; i--);
        pos = 1;
I changed it to turn off in 15 seconds since there is a 250ms delay for each time it loops i went and chaged time to equal 15 * 4(250ms delays) = 60
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips