//definition des variables LED
#define LED_R RA0_bit
#define LED_G RA1_bit
#define LED_B RA2_bit
//definition des variables BP
#define MORE_R !RB0_bit
#define LESS_R !RB1_bit
#define MORE_G !RB2_bit
#define LESS_G !RB3_bit
#define MORE_B !RB4_bit
#define LESS_B !RB5_bit
#define MODE_CHG !RB6_bit
#define OK !RB7_bit
//definitions
unsigned char R;
unsigned char G;
unsigned char B;
unsigned char PWM;
unsigned char SCRUT;
unsigned char MODE;
unsigned char COLOR;
unsigned char SPEED;
void manualMode (void);
void autoMode (void);
void outUpdate(void);
void wait(unsigned char tempo); //tempo de grosso modo 70ms
void main(){
//configuration E/S
TRISB = 0b11111111; //port B en entree uniquement
TRISA = 0b00000000; //port A en sortie uniquement
OPTION_REG = 0b00000111; //Les resistances de PullUp sont activées;TMR0=pas de 256us
//boucle du programme
while(1){
autoMode();
while(!OK){
if(MODE_CHG){
if (MODE==0){
MODE=1;
}
else if (MODE==1){
MODE=0;
}
wait(4); //anti-rebonds soft
while(MODE_CHG);
}
}
if (MODE ==0) manualMode();
else if (MODE ==1) autoMode();
}
}
void manualMode(){
R = 255;
G = 255;
B = 0;
while(!MODE_CHG){
if (PWM==0){
if (LESS_R && R>0) R--;
if (MORE_R && R<255) R++;
if (LESS_G && G>0) G--;
if (MORE_G && G<255) G++;
if (LESS_B && B>0) B--;
if (MORE_B && B<255) B++;
}
outUpdate();
}
}
void autoMode(){
COLOR=0;
R=255;G=0;B=0;
while(!MODE_CHG){
if (PWM==0){
if ((SCRUT%SPEED)==0){
switch (COLOR){
case (0): if(G<255) G++;
else COLOR++;
break;
case (1): if(R>0) R--;
else COLOR++;
break;
case (2): if(B<255) B++;
else COLOR++;
break;
case (3): if(G>0) G--;
else COLOR++;
break;
case (4): if (R<255) R++;
else COLOR++;
break;
case (5): if(B>30) B--;
else COLOR++;
break;
case (6): if(B>0){
B--; G++;
}
else COLOR=0;
}
}
SCRUT++;
if (MORE_R && SPEED>0) SPEED--;
if (LESS_R && SPEED<255) SPEED++;
}
outUpdate();
}
}
void outUpdate(void){
if(PWM<R) LED_R=1;
else LED_R=0;
if(PWM<G) LED_G=1;
else LED_G=0;
if(PWM<B) LED_B=1;
else LED_B=0;
PWM++;
}
void wait(unsigned char tempo){
while(tempo){
TMR0=1;
while(TMR0!=0);
tempo--;
}
}
0 1 mikroCPIC1618.exe -MSF -DBG -pP16F887 -DL -O11111114 -fo4 -N"C:\mer.mcppi" -SP"C:\Program Files\Mikroelektronika\mikroC PRO for PIC\defs\" -SP"C:\Program Files\Mikroelektronika\mikroC PRO for PIC\Uses\P16\" -SP"C:\" "mer.c" "__Lib_Math.mcl" "__Lib_MathDouble.mcl" "__Lib_System.mcl" "__Lib_Delays.mcl" "__Lib_CType.mcl" "__Lib_CString.mcl" "__Lib_CStdlib.mcl" "__Lib_CMath.mcl" "__Lib_Conversions.mcl" "__Lib_Sprinti.mcl" "__Lib_Sprintl.mcl" "__Lib_Time.mcl" "__Lib_Trigonometry.mcl" "__Lib_Button.mcl" "__Lib_Keypad4x4.mcl" "__Lib_Manchester.mcl" "__Lib_OneWire.mcl" "__Lib_PS2.mcl" "__Lib_Sound.mcl" "__Lib_SoftI2C.mcl" "__Lib_SoftSPI.mcl" "__Lib_SoftUART.mcl" "__Lib_ADC_88X.mcl" "__Lib_EEPROM.mcl" "__Lib_FLASH_RW.mcl" "__Lib_I2C_c34.mcl" "__Lib_PWM_c21.mcl" "__Lib_SPI_c345.mcl" "__Lib_UART_c67.mcl" "__Lib_PortExpander.mcl" "__Lib_CANSPI.mcl" "__Lib_CF.mcl" "__Lib_GlcdFonts.mcl" "__Lib_Glcd.mcl" "__Lib_LcdConsts.mcl" "__Lib_Lcd.mcl" "__Lib_RS485.mcl" "__Lib_T6963C.mcl" "__Lib_SPIGlcd.mcl" "__Lib_SPILcd.mcl" "__Lib_SPILcd8.mcl" "__Lib_SPIT6963C.mcl" "__Lib_EthEnc28j60.mcl"
0 1138 Available RAM: 352 [bytes], Available ROM: 8192 [bytes]
0 126 All files Preprocessed in 31 ms
0 122 Compilation Started C
19 392 'R' Identifier redefined C
61 318 Assigning to non-lvalue 'R' C
67 321 Lvalue required C
67 318 Assigning to non-lvalue 'R' C
68 321 Lvalue required C
68 318 Assigning to non-lvalue 'R' C
81 318 Assigning to non-lvalue 'R' C
89 321 Lvalue required C
89 318 Assigning to non-lvalue 'R' C
98 321 Lvalue required C
98 318 Assigning to non-lvalue 'R' C
116 312 Internal error '' C
0 102 Finished (with errors): 10 mars 2010, 20:56:49 mer.mcppi
I did not understand that what it means..
Can any one help me..
Thanks..