#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define LED_R1 1
#define LED_R2 2
#define LED_R3 3
#define LED_R4 4
#define LED_R5 5
#define LED_R6 6
#define LED_R7 7

#define LED_G1 8
#define LED_G2 9
#define LED_G3 10
#define LED_G4 11
#define LED_G5 12
#define LED_G6 13
#define LED_G7 14

#define LED_B1 15
#define LED_B2 16
#define LED_B3 17
#define LED_B4 18
#define LED_B5 19

#define ON   (1)
#define OFF  (0)

void Change_Ledcolor(void);
int Select_Rand_LEDstate(void);
int swflg;
int led_state;
int value;
  
void main(void)
{
	Change_Ledcolor();
}

void Change_Ledcolor(void)
{
  if(swflg == ON){
    printf("Switch_ON\n");
    switch(led_state)  {
      case(LED_R1):
        printf("COLOR_is_R1\n");
        led_state = LED_R2;
        break;
      case(LED_R2):
        printf("COLOR_is_R2\n");
        led_state = LED_R3;
        break;
      case(LED_R3):
        printf("COLOR_is_R3\n");
        led_state = LED_R4;
        break;
      case(LED_R4):
        printf("COLOR_is_R4\n");
        led_state = LED_R5;
        break;
      case(LED_R5):
        printf("COLOR_is_R5\n");
        led_state = LED_R6;
        break;
      case(LED_R6):
        printf("COLOR_is_R6\n");
        led_state = LED_R7;
        break;
      case(LED_R7):
        printf("COLOR_is_R7\n");
        led_state = LED_G1;
        break;
      case(LED_G1):
        printf("COLOR_is_G1\n");
        led_state = LED_G2;
        break;
      case(LED_G2):
        printf("COLOR_is_G2\n");
        led_state = LED_G3;
        break;
      case(LED_G3):
        printf("COLOR_is_G3\n");
        led_state = LED_G4;
        break;
      case(LED_G4):
        printf("COLOR_is_G4\n");
        led_state = LED_G5;
        break;
      case(LED_G5):
        printf("COLOR_is_G5\n");
        led_state = LED_G6;
        break;
       case(LED_G6):
        printf("COLOR_is_G6\n");
        led_state = LED_G7;
        break;
       case(LED_G7):
        printf("COLOR_is_G7\n");
        led_state = LED_B1;
        break;
      case(LED_B1):
        printf("COLOR_is_B1\n");
        led_state = LED_B2;
        break;
      case(LED_B2):
        printf("COLOR_is_B2\n");
        led_state = LED_B3;
        break;
      case(LED_B3):
        printf("COLOR_is_B3\n");
        led_state = LED_B4;
        break;
      case(LED_B4):
        printf("COLOR_is_B4\n");
        led_state = LED_B5;
        break;
      case(LED_B5):
        printf("COLOR_is_B5\n");
        led_state = LED_R1;
        break;
      default:
        printf("NO_COLOR\n");
      }
  }
  else if(swflg == OFF){
    printf("Switch_OFF\n");
  }
}

int Select_Rand_LEDstate(void)
{
  int value;
  srand(time(NULL));
  value = rand()%20+1;
  return value;
}