//eyesonly.cpp //BOOSTC++ Ver6.86 //2008.5.4 #include #pragma DATA _CONFIG, _PWRTE_ON & _WDT_OFF & _HS_OSC & _CP_OFF #pragma CLOCK_FREQ 20000000 // PIC16F84A 20MHz // --\/-- |--------------- // (LED BLUE)RA2 |1 18| RA1(LED GREEN) R____| // (NC OUTL)RA3 |2 17| RA0(LED RED) D0 D1 D2 // (NC OUTL)RA4 |3 16| OSC1(SERAROCK) B____/---\/---\/---\/ // (PULLUP)/MCLR |4 15| OSC2(SERAROCK) \___/\___/\___/\ // Vss |5 14| Vdd |------| |- // (DIPSW1)RB0 |6 13| RB7(NC RBPU) G____| |______| // (DIPSW2)RB1 |7 12| RB6(NC RBPU) // (DIPSW3)RB2 |8 11| RB5(NC RBPU) |<----9mS---->| // (RBPU NC)RB3 |9 10| RB4(NC RBPU) // ------ ///////////// //RGB CLASS ///////////// class RGB { unsigned char RED_manager; unsigned char GREEN_manager; unsigned char BLUE_manager; public: void manager(unsigned char r, unsigned char g, unsigned char b){ RED_manager = r; GREEN_manager = g; BLUE_manager = b; } void one_cycle(){ for(int i=0; i<6; i++){ porta = 0b111 & (((RED_manager) & 0b001) | ((GREEN_manager << 1) & 0b010) | ((BLUE_manager << 2) & 0b100)); RED_manager >>= 1; GREEN_manager >>= 1; BLUE_manager >>= 1; delay_10us(149); } } }; ///////////// //DIPSW input ///////////// unsigned char dipsw3inp(){ unsigned char dipsw; dipsw.0=dipsw.1=portb.0; dipsw.2=dipsw.3=portb.1; dipsw.4=dipsw.5=portb.2; return ~dipsw; } ///////////// //INITIAL ///////////// void init(){ trisa = 0; //PORTA ALL OUT MODE option_reg.7=0; //BPORT PULLUP } void main(){ init(); RGB RGB_LED; while(1){ RGB_LED.manager(0b111111, 0b000111, dipsw3inp());//R,G,B OUTPUT PATTERN RGB_LED.one_cycle(); } }