初級會員
Joined
: 2007/7/26 21:00 最後登入時間
: 2008/11/11 17:03
Group:
註冊會員
Level : 4 HP : 0 / 98 MP : 12 / 4953 EXP : 94
|
不知能不能用這支程式修改 #include "p30F4011.h" #define FCY 10000000 #define B1 LATDbits.LATD0 #define B2 LATDbits.LATD1 #define DIR_B1 TRISDbits.TRISD0 #define DIR_B2 TRISDbits.TRISD1 #define B3 LATDbits.LATD2 #define B4 LATDbits.LATD3 #define DIR_B3 TRISDbits.TRISD2 #define DIR_B4 TRISDbits.TRISD3
int i; int j;
#define input 1 #define output 0
unsigned char LEDInde = 0;
void delay_ms(int A ); //--------------------------------------------------------------------------- // Set LEDTable Value 共陰極LED
const unsigned int LEDTable[] ={0x003F,0x0006,0x005B,0x004F,0x0066,0X006D,0x007D,0x0007,0x007F,0x0067,0x0077,0x007C,0x0039,0x005E,0x0079,0x0071}; //--------------------------------------------------------------------------- // main subroutine. Initializes all modules used and turns on and off timer 1 int main(void) { ADPCFG=0xFFFF; // ADPCFG = 1111 1111 1111 1111
PORTB=0xffff; TRISB=0xffff; LATB=0xffff; // 所有 AD Input 都規劃為 Digital I/O PORTD=0xffff; TRISD=0xffff; LATD=0xffff; DIR_B1 = 0 ; // Define LED7 & 8 as Digital Outputs (Led Active Low) DIR_B2 = 0 ; DIR_B3 = 0 ; // Define LED7 & 8 as Digital Outputs (Led Active Low) DIR_B4 = 0 ; TRISBbits.TRISB0 = 0; // Define RE0 = 0 ,輸出 TRISBbits.TRISB1 = 0; // Define RE1 = 0 ,輸出 TRISBbits.TRISB2 = 0; // Define RE2 = 0 ,輸出 TRISBbits.TRISB3 = 0; // Define RE3 = 0 ,輸出 TRISBbits.TRISB4 = 0; // Define RE4 = 0 ,輸出 TRISBbits.TRISB5 = 0; // Define RE5 = 0 ,輸出 TRISBbits.TRISB6 = 0; // Define RE6 = 0 ,輸出 TRISBbits.TRISB7 = 0; // Define RE7 = 0 ,輸出
TRISEbits.TRISE0 = 0; // Define RE0 = 0 ,輸出 TRISEbits.TRISE1 = 0; // Define RE1 = 0 ,輸出 TRISEbits.TRISE2 = 0; // Define RE2 = 0 ,輸出 TRISEbits.TRISE3 = 0; // Define RE3 = 0 ,輸出 TRISEbits.TRISE4 = 0; // Define RE4 = 0 ,輸出 TRISEbits.TRISE5 = 0; // Define RE5 = 0 ,輸出 while(1) for(i=0;i<11;i++) { LATB=(int)LEDTable[LEDInde+i]; delay_ms(30000); } }
void delay_ms(int A) { for(j=0;j<A;j++); //return; }
發表於: 2008/1/30 22:34
|