View previous topic :: View next topic |
Author |
Message |
shamanjum
Joined: 21 May 2013 Posts: 7
|
I have a Problem!! led dot matrix 8x8 control by switch |
Posted: Tue May 21, 2013 9:29 am |
|
|
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
|
|
Posted: Tue May 21, 2013 10:25 am |
|
|
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:
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
|
|
Posted: Tue May 21, 2013 11:39 am |
|
|
Thank you very much. |
|
|
shamanjum
Joined: 21 May 2013 Posts: 7
|
|
Posted: Wed May 22, 2013 8:22 am |
|
|
Prrblem!! output ? I don't understand output. |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Wed May 22, 2013 9:10 am |
|
|
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
|
|
Posted: Wed May 22, 2013 9:19 am |
|
|
Yeah , I need datasheet. I have 5 hour for finish. |
|
|
shamanjum
Joined: 21 May 2013 Posts: 7
|
|
Posted: Wed May 22, 2013 9:37 am |
|
|
Hi John
I can't coding , Help me please. T_T |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed May 22, 2013 12:48 pm |
|
|
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
|
|
Posted: Wed May 22, 2013 11:31 pm |
|
|
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
|
|
Posted: Wed May 22, 2013 11:57 pm |
|
|
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
|
|
Posted: Wed May 22, 2013 11:59 pm |
|
|
Sorry. Led teacher's makes. Not number. T_T |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Thu May 23, 2013 6:49 am |
|
|
Hi,
Please post your teachers contact info, and we will contact them directly!
John |
|
|
|