Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "C:\Users\Administrat0r\Desktop\Projects\BRAD_USB_CUSTOM_BOARD\b-rad.h"
- unsigned int8 LEDAddr[6];
- unsigned int8 LED[8];
- //char EPRAM[240];
- //C7 Is Rx
- void allOff(){
- output_c(0x00);
- output_a(0x00);
- }
- void allOn(){
- /*int i=0;
- for(i=0; i<6; i++){
- output_high(LEDAddr[i]);
- }*/
- output_c(0xFF);
- output_a(0xFF);
- }
- /*void writeEPR(unsigned int8 addr, unsigned int8 data){
- EPRAM[addr]=data;
- }
- unsigned int8 writeEPR(unsigned int8 addr){
- return EPRAM[addr];
- }*/
- void main()
- {
- unsigned int8 PWMcounter=0;
- unsigned int8 phase=0, i=0,b=0;
- unsigned int16 phaseCount=0, phaseCount2=0, phaseCount3=0;
- setup_adc_ports(NO_ANALOGS|VSS_VDD);
- setup_adc(ADC_OFF);
- setup_spi(SPI_SS_DISABLED);
- setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
- setup_timer_1(T1_DISABLED);
- setup_timer_2(T2_DISABLED,0,1);
- setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
- setup_oscillator(OSC_8MHZ);
- // TODO: USER CODE!!
- LEDAddr[0]=PIN_C1;
- LEDAddr[1]=PIN_A2;
- LEDAddr[2]=PIN_C0;
- LEDAddr[3]=PIN_A3;
- LEDAddr[4]=PIN_A6;
- LEDAddr[5]=PIN_A4;
- set_tris_c(0b10110000);
- for(i=0; i<6; i++){
- LED[i]=0;
- }
- allOn();
- while(true){
- switch(phase){
- case 0:{
- if(phaseCount>=3){
- for(i=0; i<6; i++){
- LED[i]++;
- }
- phaseCount=0;
- if(LED[0]>=50){
- phase++;
- }
- }
- break;
- }
- case 1:{
- if(phaseCount>=6){
- phaseCount=0;
- if(phaseCount2==0){
- for(i=0; i<6; i++){
- LED[i]--;
- }
- if(LED[0]==30) phaseCount2++;
- }
- else if(phaseCount2==1){
- for(i=0; i<6; i++){
- LED[i]++;
- }
- if(LED[0]==50) {
- phaseCount3++;
- phaseCount2--;
- if(phaseCount3==7){
- phase++;
- phaseCount3=0;
- phaseCount2=0;
- phaseCount=0;
- }
- }
- }
- }
- break;
- }
- case 2:{
- if(phaseCount>=3){
- for(i=0; i<6; i++){
- LED[i]--;
- }
- phaseCount=0;
- if(LED[0]==0){
- phase++;
- }
- }
- break;
- }
- case 3:{
- if(phaseCount3==0){
- LED[0]=15;
- LED[1]=15;
- LED[2]=40;
- LED[3]=40;
- LED[4]=15;
- LED[5]=15;
- phaseCount3++;
- }
- else{
- if(phaseCount==3){
- phaseCount=0;
- b=LED[5];
- LED[5]=LED[3];
- LED[3]=LED[1];
- LED[1]=b;
- b=LED[4];
- LED[4]=LED[2];
- LED[2]=LED[0];
- LED[0]=b;
- phaseCount2++;
- if(phaseCount2%35==0){
- for(i=0; i<6; i++){
- if(LED[i]>30)LED[i]+=1;
- }
- }
- if(phaseCount2==200){
- phaseCount3=0;
- phaseCount2=0;
- phaseCount=0;
- phase++;
- for(i=0; i<6; i++){
- LED[i]=15;
- }
- LED[0]=50;
- }
- }
- }
- break;
- }
- case 4:{
- if(phaseCount==4){
- phaseCount=0;
- b=LED[5];
- LED[5]=LED[4];
- LED[4]=LED[3];
- LED[3]=LED[2];
- LED[2]=LED[1];
- LED[1]=LED[0];
- LED[0]=b;
- phaseCount2++;
- if(phaseCount2==300){
- phaseCount3=0;
- phaseCount2=0;
- phaseCount=0;
- phase=0;
- for(i=0; i<6; i++){
- LED[i]=0;
- }
- }
- }
- break;
- }
- }
- for(i=0; i<6; i++){
- if(PWMcounter>=LED[i]){
- output_low(LEDAddr[i]);
- }
- }
- PWMcounter++;
- if(PWMcounter>=50){
- allOn();
- PWMcounter=0;
- phaseCount++;
- //for(i=0; i<6; i++){
- // LED[i]++;
- //}
- }
- }
- }
Add Comment
Please, Sign In to add comment