LEDs lighting

Thread Starter

alex90

Joined Nov 27, 2013
2
Hi guys,

I am very new to embedded systems and I have very little knowledges about them and electronics.
Recentrly I started to read a book(a little old) and I need some explanations about how the LEDs are illuminated because it didn't explain on the book.I use Pickit 1 flash starter kit, and a PIC16f684.
Here is the diagram of LEDs(from my Pickit 1 flash starter kit user's guide)


Here is the diagram from the old book:


The C code is here:

Rich (BB code):
#include<pic.h>

__CONFIG(INTIO & WDTDIS & PWRTEN & MCLRDIS & UNPROTECT & BORDIS & IESODIS & FCMDIS);

main()
{
	PORTA = 0;
	CMCON0 = 7;
	ANSEL = 0;
	TRISA = 0b001001;
	
	while(1 == 1)
	{
		if(0 == RA3)
		PORTA = 0b010010;
		
		else 
		PORTA = 0b000100;
	
	}
}
When I press the switch button the 0 and 7 LEDs are full lit and the 2 LED is lit but less then two others.
When I release the button, 3, 5 and 6 LEDs are illuminated with the same power.
So please if you can explain me why some LEDs are illuminated more than others or have the same power.I really want to learn embedded systems and I know I need electronics, but I believe that with your help I will succeed.
Thank you and excuse me for my english if it is bad.
 
Last edited by a moderator:

Markd77

Joined Sep 7, 2009
2,806
The normal way to use Charlieplexing (the name for the way these LEDs are wired up) is to set one pin to 1, another pin to 0, and to have all the other pins set to input so no current flows in them. That way there is one LED lit at full power. If you want it to appear that more than on LED is on then alternate between them fast enough that the eye can't tell the difference. With more than two pins set as outputs it quickly gets confusing.
 

bwack

Joined Nov 15, 2011
113
There are a couple of basic principles you need to know about electronics. The voltage law (KVL) and the current law (KCL).

The sum of each voltage drop equals the total voltage in the circuit.
The sum of each branch of current running into a point equals zero.

In practice this means, if you have a device that drops 2V (the red led infact), you can subtract that from the total (5V battery), and the rest will lay over the rest of the circuit. Do this for both pressed and unpressed. PORTA=0b010010; means that RA1=RA4=5V, RA2=RA5=0V.
Sorry I was interrupted. I'll finnish maybe later.
 
Last edited:

bwack

Joined Nov 15, 2011
113
Markd77 said:
With more than two pins set as outputs it quickly gets confusing.
I was going to draw the currents on the schematics, but it got quite confusing with the four pins as outputs. Maybe node analysis has to be done to show why some leds are brighter than others.
 

Art

Joined Sep 10, 2007
806
Does this lesson 1 source code and schematic belong together and provided by Microchip?
I hope the future lessons are more relevant to the hardware.

Is this that little development board that comes with a pickit?

Lesson one is a pile of ****, and should only have dealt with two of those LEDs.
 
Top