Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC16F877A_mikroC PRO_16xLED chaser

Status
Not open for further replies.

va_cristi

Newbie level 4
Newbie level 4
Joined
Oct 18, 2012
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,314
16xled_chaser.JPGHi,

Please help me modify this program.
I would like to make LEDs of PORTB to PORTC to continue.
Thanks in advance.
I have the following code:


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
unsigned int cnt=0;
 
bit up;
bit down;
 const char number1[80]={0x00,0x01,0x03,0x06,0x0c,0x18,0x30,0x60,0xc0,0x81};
 
 
char count;     
 
 
void main() {
 
TRISD=0xFF;
TRISB=0x00;
TRISC=0x00;
do
  {
 if(portd.f0==1){
  up=1;
  }
 
 
  if(portd.f1==1){
  down=1;
  }
 
 
 if(up && portd.f0==0){
  up=0;
  cnt++;
      // if(cnt>9999){
      if(cnt>32){          
      //cnt=7;              
      cnt=0;               
      }
 }
 
 
if(down && portd.f1==0){
  down=0;
  --cnt;
      // if(cnt>9999){
      if(cnt>32){          
      //cnt=0;              
      cnt=7;               
      }
 }
 
 count = cnt/1;
 
 PORTB = number1[count];
 Delay_ms(5); 
 
 }  while(1);
}

 
Last edited by a moderator:

Near the end, change "PORTB = number1[count];" to "PORTB = number1[count % 10];" and...
add a line after it saying "PORTC = number1[count / 10];"

That will split the value in "count" into tens and units digits and display then on PORTB and PORTC. If you are using hexadecimal, change the 10 to 16.

I have no facilities here to test it at the moment but I think it will do what you want.

Brian.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top