# Help needed for programming PIC16F877A...

#### nerdegutta

Joined Dec 15, 2009
2,684
Is this another project?

#### ErnieM

Joined Apr 24, 2011
8,346
Hi,

I am working with 4017 connected through 877 for controling LED as per schematic the problem is that i am not getting how to control the Reset pin 15 of 4017 to avoid counting upto 10 i.e. stop at 8 only..??
First you look up the spec of the 4017 to see how to control the clock pin 14 and the reset pin 15 of the 4017.

Then you use the clock pin to "bit bang" the clock line to count up to the desired number.

Once you know you are at that number and want to "count back to zero" you hit the reset line instead of the clock line.

#### thatoneguy

Joined Feb 19, 2009
6,359
May I suggest searching for a "Beginning Programming in PIC C" course on the net?

You will then get everything from foundations to syntax, then loops, functions, and pointers. At that time, you would be an average programmer, but able to expand.

Everybody learns languages differently. I can't really think of a way to write a course to post here on learning C, that would have all the platforms covered, and still be understandable.

YES, it is money, but so is food, and our time. Members are doing the absolute best they can to help you, though you seem to find and attempt a different example without even reading the replies which members here have put time and effort into providing for you.

It appears that you are jumping from the "Hello World" of microcontrollers (blink an LED) straight to either an LED Cube or a scrolling display matrix. There is a world of difference between the two!

#### RRITESH KAKKAR

Joined Jun 29, 2010
2,829
Is this another project?

Not like project just moving forward after using if else. foor loop to simple output to LEDs..

First you look up the spec of the 4017 to see how to control the clock pin 14 and the reset pin 15 of the 4017.

Then you use the clock pin to "bit bang" the clock line to count up to the desired number.

Once you know you are at that number and want to "count back to zero" you hit the reset line instead of the clock line.
Everything work fine while connecting the reset pin to serial output at 9 of 4017 but when i connect the uC to Led matrix it start from any Row but i want it to start from 1st Row only!!

the code i am writing is simple

TRISB=0X00;
PORTB=0B00101010;
LIKE THIS WORKING FINE BUT THE PROBLEM IS RESET..

#### nerdegutta

Joined Dec 15, 2009
2,684
TRISB=0X00;
PORTB=0B00101010;
LIKE THIS WORKING FINE BUT THE PROBLEM IS RESET..
I guess that is not your whole code....

#### ErnieM

Joined Apr 24, 2011
8,346
Everything work fine while connecting the reset pin to serial output at 9 of 4017 but when i connect the uC to Led matrix it start from any Row but i want it to start from 1st Row only!!

LIKE THIS WORKING FINE BUT THE PROBLEM IS RESET..
Of course you want that, so why don't you do that?

As you start, do the reset.

#### t06afre

Joined May 11, 2009
5,934
If you are still using the 16F877a you will have enough pins to drop using the CD4017

#### RRITESH KAKKAR

Joined Jun 29, 2010
2,829
If you are still using the 16F877a you will have enough pins to drop using the CD4017

Sorry, i don't get you?

#### RRITESH KAKKAR

Joined Jun 29, 2010
2,829
Please help to build algorithm how to do this as the code will be very long if i will do ths with simple output statements ..

#### RRITESH KAKKAR

Joined Jun 29, 2010
2,829
Hi,

I have changed 4017 with 74164 shift register...for i am having problem with serial converting data to storage in 74164 then display while scanning. please tell how to do this??

#### RRITESH KAKKAR

Joined Jun 29, 2010
2,829
OK, As i was talking about matrix display i want your suggestion which method should i use for scanning rows i have got 270 LED 3mm RED colours...??
1. 3 to 8 decoder
2. 4017
3. Or direct to PORTB,???

#### RRITESH KAKKAR

Joined Jun 29, 2010
2,829
Hi,

I have made led matrix layout in PCB123...pls suggest is there any problem in it??

#### Attachments

• 93.1 KB Views: 13
• 48.9 KB Views: 12

#### RRITESH KAKKAR

Joined Jun 29, 2010
2,829
The code is working fine.....
please tell how to add string while selecting its array row column automatically..??

Rich (BB code):
#include <htc.h>
__CONFIG(LVP_OFF & BOREN_OFF & PWRTE_ON & WDTE_OFF & FOSC_XT);
#define _XTAL_FREQ 4000000
#define RST RD7
#define CLK RD4
#define DATA RD5
#define D 1
extern const unsigned char Font2[32][7];
int data(int a);
main (){
TRISD=0B00000000;
TRISB=0B00000000;
while(1){
int a;

for(int i=1;i<32;i++){

for (int k=0;k<100;k++){
int o=0;
a=Font2[o];
data(a);
__delay_ms(D);
o++;

a=Font2[o];
data(a);
__delay_ms(D);
o++;
a=Font2[o];
data(a);
__delay_ms(D);
o++;
a=Font2[o];
data(a);
__delay_ms(D);
o++;
a=Font2[o];
data(a);
__delay_ms(D);
o++;
a=Font2[o];
data(a);
__delay_ms(D);
o++;
a=Font2[o];
data(a);
__delay_ms(D);
o++;

}
}
}
}

int data(int a)
{
RST=0;
RST=1;

for (int k=0; k<8;k++) {
CLK = 0;
if ((a & 0x01)==1) DATA = 1;

else DATA =0;

CLK =1;

a >>=1;
} }