CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

I have a Problem!! led dot matrix 8x8 control by switch

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
shamanjum



Joined: 21 May 2013
Posts: 7

View user's profile Send private message

I have a Problem!! led dot matrix 8x8 control by switch
PostPosted: Tue May 21, 2013 9:29 am     Reply with quote

I'm Thai. English I'm not sure. I have a problem, Led dot matrix 8x8. I need use switch control LED. Click switch 1 for left, Switch 2 for right, switch 3 for up, switch 4 for down. By LED col use port b, LED row use port d, Switch use port a0,a1,a2,a3 . If wrongs I'm not good at English. Thanks.
Code:

#include <16F877.h>
#fuses HS,NOWDT,NOPROTECT,NOBROWNOUT,NOLVP,NOPUT,NOWRT,NODEBUG,NOCPD
#use delay(clock=20000000)

#define    left_sw      input(PIN_A0)
#define    right_sw     input(PIN_A1)
#define    up_sw        input(PIN_A2)
#define    down_sw      input(PIN_A3)


void main(void){

int i = 0;
int disp_buff[];


set_tris_b(0x00);
set_tris_d(0x00);

while(TRUE){

if(!left_sw){
    for(i=0;i<8;i++){
   
        disp_buff[i] <<= 1;
    }
        output_b(disp_buff[i]) ;     
   output_d(~(1 << i));       
   delay_ms(50);
   i++;
    }


if(!right_sw){
    for(i=0;i<8;i++){
        disp_buff[i] >>= 1;
    }
        output_b(disp_buff[i]) ;     
   output_d(~(1 << i));       
   delay_ms(50);
   i++;
   
}



if(!up_sw){
    for(i=0;i<8;i++){
        disp_buff[i] = disp_buff[(i+1)&7] ;
    }
        output_b(disp_buff[i]) ;     
   output_d(~(1 << i));        /
   delay_ms(50);
   i++;
   
}




if(!down_sw){
    for(i=0;i<8;i++){
        disp_buff[i] = disp_buff[(i-1)&7] ;
    }
        output_b(disp_buff[i]) ;     
   output_d(~(1 << i));       
   delay_ms(50);
   i++;
    }
   
}
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue May 21, 2013 10:25 am     Reply with quote

Quote:
void main(void){

int i = 0;
int disp_buff[];

In your code above, disp_buff is not an array. It's just a pointer. You
need to put the size of the array inside the brackets. Then the compiler
will allocate ram to the array, and you can save data in the array.
For example:
Code:
int disp_buff[8];



The switch circuits should look like this for pins A0, A1, A2, A3:
Code:
           +5v
            |
            <
            > 4.7K       
            <         ___  Switch 
To          |        _|_|_
PIC -----------------o   o------
pin                            |             
                              --- GND
                               -   
 

The pull-up resistor can be 10K or some other reasonable value.
shamanjum



Joined: 21 May 2013
Posts: 7

View user's profile Send private message

PostPosted: Tue May 21, 2013 11:39 am     Reply with quote

Thank you very much.
shamanjum



Joined: 21 May 2013
Posts: 7

View user's profile Send private message

PostPosted: Wed May 22, 2013 8:22 am     Reply with quote

Prrblem!! output ? I don't understand output.
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Wed May 22, 2013 9:10 am     Reply with quote

shamanjum wrote:
Prrblem!! output ? I don't understand output.


Hi,

Can you be more specific? Do you mean you don't understand the 'output_x' statement? Have you looked at the CCS manual? Did you write the code shown in your original post in this thread?

John
shamanjum



Joined: 21 May 2013
Posts: 7

View user's profile Send private message

PostPosted: Wed May 22, 2013 9:19 am     Reply with quote

Yeah , I need datasheet. I have 5 hour for finish.
shamanjum



Joined: 21 May 2013
Posts: 7

View user's profile Send private message

PostPosted: Wed May 22, 2013 9:37 am     Reply with quote

Hi John

I can't coding , Help me please. T_T
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed May 22, 2013 12:48 pm     Reply with quote

Post a schematic of your circuit on a free image hosting service such
as http://www.imageshack.us and then post a link to the image here.
shamanjum



Joined: 21 May 2013
Posts: 7

View user's profile Send private message

PostPosted: Wed May 22, 2013 11:31 pm     Reply with quote

Code:



To  RB 0- 7 -------------------- R x 8 --------------------|
                                                                             o +
Pin                                                           LED 8x8 matrix
                                                                             o -
Pic  RD 0 - 7 ---------------------------------------------- |
  |
  |-- RA0 - 3 -----------------------------------Switch -------- R ------- +5v





Sorry I don't have Proteus.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed May 22, 2013 11:57 pm     Reply with quote

Post the manufacturer and part number of your LED array.
If you have a link to the data sheet for it, post it.
shamanjum



Joined: 21 May 2013
Posts: 7

View user's profile Send private message

PostPosted: Wed May 22, 2013 11:59 pm     Reply with quote

Sorry. Led teacher's makes. Not number. T_T
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Thu May 23, 2013 6:49 am     Reply with quote

Hi,

Please post your teachers contact info, and we will contact them directly!

John
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group