# Learn Embedded Programming [Step by Step]

## Battery Charge Level Indicator (5volt) using Microcontroller

Battery Charge Level Viewer is a microcontroller based small project which shows charge level of battery using 5 LEDs . Generally battery becomes full at 5volts . Remember that an ADC channel of pic18f2550 can count from 0 to 1023 . Because it's ADC channel register is 10bits. As we like to  measure 5volt  . We will read the value of adc channel and will convert it to voltage . After converting into voltage we get a understandable value and we shows it through 5 green LEDs. It's the basic concept .

### ADC(Analog to Digital Converter ) :

We need a basic knowledge about ADC . Let's  take a look at here :

Basically ADC is like as voltage divider . According to voltage It produce output .

bit 5 : VCFG0: Voltage Reference Configuration bit (VREF- source)
1 = VREF- (AN2)
0 = VSS or 0 volt

bit 4 :VCFG0: Voltage Reference Configuration bit (VREF+ source)
1 = VREF+ (AN3)
0 = VDD or 5volt

We will set  VCFG0[bit 5]=0and VCFG0[bit4]=0 . So we will get highest value 5volt[1023] and lowest value 0volt[0].The ADCON1 is a 10 bit register that means  2 to the power 10  is it's highest counting capacity and result is 1024 . So this register can count from 0 to 1023 . When 0 volt , we get reading at RA0 pin  0 .When 5 volt , we get reading at RA0 pin 1023. It means 5volt equivalent to 1023 .

If  1023 reading value    equal   to 5 volt.
So 1      reading value    equal   to  5/1023 volt

## Source Code :

``````

void main() {
int source=0;
ADCON1=0x0E;                 // Configuring RA0 pin as input
CMCON=7;
TRISB=0x00;
PORTB.F0=0;
PORTB.F1=0;
PORTB.F2=0;
PORTB.F3=0;
PORTB.F4=0;

while(1){

PORTB.F0=0;
PORTB.F1=0;
PORTB.F2=0;
PORTB.F3=0;
PORTB.F4=1;
}
PORTB.F0=0;
PORTB.F1=0;
PORTB.F2=0;
PORTB.F3=1;
PORTB.F4=1;
}
PORTB.F0=0;
PORTB.F1=0;
PORTB.F2=1;
PORTB.F3=1;
PORTB.F4=1;
}
PORTB.F0=0;
PORTB.F1=1;
PORTB.F2=1;
PORTB.F3=1;
PORTB.F4=1;
}
PORTB.F0=1;
PORTB.F1=1;
PORTB.F2=1;
PORTB.F3=1;
PORTB.F4=1;
}
}
}``````

## Circuit :

 circuit

## Thank You!

1. So So much help full for me this topic . many many thanks

2. I was more than happy to uncover this great site. I need to thank you for your time due to this fantastic read!!
I definitely enjoyed every bit of it and I have you bookmarked to see new information on your blog.
WordPress Chat Plugin

3. I was more than happy to uncover this great site. I need to thank you for your time due to this fantastic read!!
I definitely enjoyed every bit of it and I have you bookmarked to see new information on your blog.
humidifier dehumidifier combo

4. When I try to download I first I got a 404 error and now it shows the site has malicious software and my Malware Bytes blocks it. I am actually looking for this exact design. Is there any other place to download from?

5. I am glad you take pride in what you write. This makes you stand way out from many other writers that push poorly written content. dime cart

## Course by The University of Texas at Austin

(FREE Edx Course) Embedded Systems - Shape The World: Microcontroller Input/Output. Offered by The University of Texas

## Become a Robotics Software Engineer- Udacity Course

Ain't getting any visitors!

## Tags

: (1) 18F2550 (1) 36KHz (3) and (1) arduino (1) Based (1) battery (1) Bipolar (1) Blinking (1) blinks (1) Bluetooth (1) button (1) circuit (1) clock (1) control (1) Db9 (1) DC Motor (2) digital (2) display (2) DS1307 (1) electronic (1) flash (1) flashing (1) HC-06 (1) home (1) how (1) How to (10) i2c tutorial (1) in (1) indicator (1) interface (8) interfacing (3) Interrupt (3) Introduction (1) IR Receiver (4) key pad (1) keyboard (1) keypad (1) lavel (1) Lcd 16x2 (2) lcd 2x16 (2) led (1) lm35 (2) LPG (1) machine (1) make (1) making (1) matrix (1) max232 (1) meter (2) microchip (4) microchips (3) mikroC (5) musical (1) NEC Protocol (4) pcb (5) PIC (3) pic controller (11) pic proteus (1) Pic Tutorial (12) pic18 (2) pic18f2550 (11) picRFモジュール (1) proteus (6) push (1) push button (1) PWM (1) real (1) Rs 232 (1) Rs232 (1) scroll (1) scrolling (1) Serial Port (1) simulation (2) step by step (7) step bystep (1) text (2) time (1) timer (4) timer0 (4) tone (1) tutorial (2) Unipolar (1) USB (1) usb 1.0 (1) USB HID (1) using (9) voltmeter (1) voting (1) with (2) work (1)

## Traffic Feed

Live Traffic Feed
Visitor Tracking