const float BETA = 3950; // should match the Beta Coefficient of the thermistor

// These constants should match the photoresistor's "gamma" and "rl10" attributes
const float GAMMA = 0.7;
const float RL10 = 50;

void setup() {
  // put your setup code here, to run once:
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:



int sel=analogRead(5);
sel=map(sel,0,1023,0,7);

switch (sel){
case 0:
  ch0();
break;

case 1:
  ch1();
break;

case 2:
  ch2();
break;

case 3:
  ch3();
break;

case 4:
  ch4();
break;

case 5:
  ch5();
break;

case 6:
  ch6();
break;

case 7:
  ch7();
break;
}
delay(200);


}
void ch0(){
 Serial.print("ch 0 =");
Serial.println(analogRead(0));
digitalWrite(7, LOW);
digitalWrite(6, LOW);
digitalWrite(5, LOW);
digitalWrite(4, LOW);

}
void ch1(){
  Serial.print("ch 1 =");
Serial.println(analogRead(0));
digitalWrite(7, HIGH);
digitalWrite(6, LOW);
digitalWrite(5, LOW);
digitalWrite(4, LOW);

}
void ch2(){
  Serial.print("ch 2 =");
Serial.println(analogRead(0));
digitalWrite(7, LOW);
digitalWrite(6, HIGH);
digitalWrite(5, LOW);
digitalWrite(4, LOW);

}
void ch3(){
  Serial.print("ch 3 =");
Serial.println(analogRead(0));
digitalWrite(7, HIGH);
digitalWrite(6, HIGH);
digitalWrite(5, LOW);
digitalWrite(4, LOW);

}
void ch4(){
  Serial.print("ch 4 =");
Serial.println(analogRead(0));
digitalWrite(7, LOW);
digitalWrite(6, LOW);
digitalWrite(5, HIGH);
digitalWrite(4, LOW);

}
void ch5(){
  int analogValue = analogRead(0);
float celsius = 1 / (log(1 / (1023. / analogValue - 1)) / BETA + 1.0 / 298.15) - 273.15;
  Serial.print("Temperature 1 =");
  Serial.print(celsius);
  Serial.println(" ْC");
  delay(2000);

digitalWrite(7, HIGH);
digitalWrite(6, LOW);
digitalWrite(5, HIGH);
digitalWrite(4, LOW);


}
void ch6(){
  int analogValue = analogRead(0);
float celsius = 1 / (log(1 / (1023. / analogValue - 1)) / BETA + 1.0 / 298.15) - 273.15;
  Serial.print("Temperature 2 =");
  Serial.print(celsius);
  Serial.println(" ْC");
  delay(1000);
  
digitalWrite(7, LOW);
digitalWrite(6, HIGH);
digitalWrite(5, HIGH);
digitalWrite(4, LOW);

}
void ch7(){
  // Convert the analog value into lux value:
int analogValue = analogRead(0);
float voltage = analogValue / 1024. * 5;
float resistance = 2000 * voltage / (1 - voltage / 5);
float lux = pow(RL10 * 1e3 * pow(10, GAMMA) / resistance, (1 / GAMMA));

  Serial.print("Ldr 1 =");
  Serial.println(voltage);
  Serial.println(resistance);
  Serial.println(lux);
  delay(1500);
//Serial.println(analogRead(0));
digitalWrite(7, HIGH);
digitalWrite(6, HIGH);
digitalWrite(5, HIGH);
digitalWrite(4, LOW);

}
$abcdeabcde151015202530354045505560fghijfghij
Loading
cd74hc4067