Software

The following algorithm was designed for regulating the brightness of the stars on the night sky board. The stars are represented by LED lights of various colors (yellowish, reddish, whitish) depending on their actual color on the night sky. The brightness of the stars depends on two factors, the first is the park light fixtures intensity and the second is the color type LED lights that are placed in the park. Those two outputs are the “a” and “b”, that the Arduino code controls, where referring to a to light fixtures and b to stars. The input information is collected through the signal that is fed to Arduino board via the two switches terminals. The Switch number 1 has three positions including the zero place, the one which is color temperature 3000K -warm light and the two which is 6500K cold light. It is known that the cold light is more disturbing causes more light pollution, and stars seems fainter. Those three terminals have the if case scenario that leads to given value equal to 1 and value2 equal to 1 (Warm lights on) or value equal to 2 and value2 equal to 1 (Cold lights on). Considering the Switch Number 2, which can go to one or another position and returns always to zero, is regulated by the parameter called count. Let’s assume that the switch number 2 goes up the counter is increased to 1 which controls the star brightness related with the output b (stars are brighter), meanwhile the a has to lower its intensity.

Serial print is the print screen command for programmer aid. Whatever has “ // “ is considered as a comment, which is inserted to inform you about the delay.

Technical details in the code:

//DEFINITION SETUP

int pwm_a = 9;  //light fixtures

int pwm_b = 3;  //stars

 

int sensorPin= 42;   // Pins position (Switch number 1)

int sensorPin2= 43; // Pins position (Switch number 1)

int sensorPin3= 30; // Pins position (Switch number 2)

int sensorPin4= 31; // Pins position (Switch number 2)

 

int sensorValue = 0;     // Initiate the sensor value (pins of Switch number 1)

int sensorValue2 = 0; // Initiate the sensor value (pins of Switch number 1)

int sensorValue3 = 0; // Initiate the sensor value (pins of Switch number 2)

int sensorValue4 = 0; // Initiate the sensor value (pins of Switch number 2)

 

int count=0;

int value=0;

int value2=0;

 

// MAIN PROGRAM

void setup() {

Serial.begin(9600);  // Console output

pinMode(pwm_a, OUTPUT);  //Set control pins to be output

pinMode(pwm_b, OUTPUT); //Set control pins to be output

}

 

void loop() {

// put your main code here, to run repeatedly:

 

sensorValue=digitalRead(sensorPin);

delay(100);

sensorValue2=digitalRead(sensorPin2);

delay(100);

sensorValue3=digitalRead(sensorPin3);

delay(100);

sensorValue4=digitalRead(sensorPin4);

delay(100);

 

if (sensorValue==HIGH &&sensorValue2==LOW){

Serial.print(“Warm light”);

value=1;

value2=1;

}

if (sensorValue2==HIGH &&sensorValue==LOW){

Serial.print(“Cold light”);

value=2;

value2=1;

}

 

if(sensorValue3==LOW){

count+=1;

//  Serial.print(count);

// delay(1000);

//Serial.print(“\t”);

}

if(sensorValue4==LOW && count>0){

count-=1;

//Serial.print(count);

//delay(1000);

//Serial.print(“\t”);

}

 

if(count==1){

analogWrite(pwm_a, 4/value);

analogWrite(pwm_b, 80/value);

// delay(2000);

}

 

if(count==2){

analogWrite(pwm_a, 20/value);

analogWrite(pwm_b, 60/value);

//delay(1000);

}

 

if(count==3){

analogWrite(pwm_a, 60/value);

analogWrite(pwm_b, 20/value);

//delay(1000);

}

 

if(count==4){

analogWrite(pwm_a, 80/value);

analogWrite(pwm_b, 4/value);

//delay(1000);

}

if (count>4){

count=4;

}

if (count<0){

count=0;

}

}