Led blinking not working in breadboard

Thread Starter

PY01A0080

Joined Mar 7, 2013
42
Hi,
i try the very simple led blinking code with 8051.
it's working well in Proteus and in a development card for 8051 but not in breadboard.
can someone explain me the reason please, i don't understand or i don't the see obvious default in my breadboard.

thank you
 

DerStrom8

Joined Feb 20, 2011
2,390
Hi,
i try the very simple led blinking code with 8051.
it's working well in Proteus and in a development card for 8051 but not in breadboard.
can someone explain me the reason please, i don't understand or i don't the see obvious default in my breadboard.

thank you
Please post the schematic you followed to make the connections on your breadboard.

Chances are you're missing a connection. Either that, or you put too much voltage into it and destroyed it.

We need a lot more details before we can really answer your question.

Regards,
Matt
 

Thread Starter

PY01A0080

Joined Mar 7, 2013
42
Ok so here is the code:

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

sbit led1 = P1^0;
sbit led2 = P1^1;

void delay(unsigned int msec)  // Function to provide time delay in msec.
{
int i,j ;
for(i=0;i<msec;i++)
for(j=0;j<1275;j++);
}

void main()
{
while(1)
{ 
if(led1 == 1)
{
led1 = 0;
led2 = 1;
delay(50);
}   

else{
led1 = 1;
led2 = 0;
delay(50);
}
}
}
The proteus diagram is attached.
With the breadboard i put the:
+5Vdc to pin(40)
Ground to pin (20)
the crystal (11.0592 Mhz) between pins (18) and (19)
i connected two 33pF to the crystal like in the proteus image.
and that's all, nothing else.


Other thing i tried different time delay too.

it happens nothing.
Thank you
 

Attachments

DerStrom8

Joined Feb 20, 2011
2,390
Is that the exact code you're using?

In your delay function you forgot a semicolon:

Rich (BB code):
void delay(unsigned int msec)  // Function to provide time delay in msec. 
{ 
   int i,j ; 
   for(i=0;i<msec;i++);  <==
   for(j=0;j<1275;j++); 
}
 

kubeek

Joined Sep 20, 2005
5,794
I think that missing semicolon is correct, it makes a nested loop. Also with the semicolon using two different variables wouldn´t make much sense.

You are missing the current limiting resistors on those leds, so they might already be toast.
 

LDC3

Joined Apr 27, 2013
924
Actually, to have a nested loop, the semicolon should be located after the 2nd 'for' statement.

Rich (BB code):
void delay(unsigned int msec)  // Function to provide time delay in msec. 
{ 
   int i,j ; 
   for(i=0;i<msec;i++)
   for(j=0;j<1275;j++); ;
}
 

DerStrom8

Joined Feb 20, 2011
2,390
Oops, you're right. I take it one millisecond is 1275 cycles?

LCD3, you do not want two semicolons on the same row. The OP had it programmed correctly.
 

Thread Starter

PY01A0080

Joined Mar 7, 2013
42
i didn't burn my leds without resistors.
but ok now i have resistors to protect leds but still there is nothing.
what could be the problem?
the circuit is very simple.
 

DerStrom8

Joined Feb 20, 2011
2,390
i didn't burn my leds without resistors.
but ok now i have resistors to protect leds but still there is nothing.
what could be the problem?
the circuit is very simple.
How do you know your LEDs aren't burnt out? Did you test them to make sure?

Also, check that you have pin 9 connected to ground (it's reset when held high, so you should connect it to ground through a pull-down resistor, if you're using a switch, or directly to ground if you don't want to reset it. Also check that pin 31 is connected to 5v as well.
 

Thread Starter

PY01A0080

Joined Mar 7, 2013
42
I checked leds with my multimeter and they are good.
i connected the pin 9 directly to ground and the pin 31 to 5V
as you mentioned but nothing, leds are off and i have :
5V in pin 40 and 31
0V at pin 1 and 2 for leds
5V at pin 18
1.38V at pin 19

so is there a problem with my breadboard which is new....
 

DerStrom8

Joined Feb 20, 2011
2,390
0V at pin 1 and 2 for leds
5V at pin 18
1.38V at pin 19

so is there a problem with my breadboard which is new....
What do you mean you have "0V at pin 1 and 2 for leds"?

You should not have 5v at pin 18. Check your ground connections. If you connected ground to 5V and vice versa, you probably fried your chip.
 

Thread Starter

PY01A0080

Joined Mar 7, 2013
42
I mean Led are connected to P1.0 and P1.1 which are pin 1 and 2, there is 0V, leds are off.

i have 5V at pin18 where one of the crystal's pin is connected.

i did not connected 5V to the ground
 

DerStrom8

Joined Feb 20, 2011
2,390
Make sure your chip isn't backwards. Could you please post a photo of your setup?

Also, how are you loading your code onto the chip?
 

LDC3

Joined Apr 27, 2013
924
It's hard to tell if the capacitors near the crystal are one on each side of the crystal. Should there also be a resistor with the crystal?
 
Top