This image shows a simple diagram based on images of the final box corresponding to the more detailed block diagram shown below. The box begins in the standby state once plugged in, waiting for user input (button push). Once the button is pushed a disinfection cycle begins including a sensor voltage and countdown timer display. The state of the sensors is constantly checked to ensure their proper function.
In state A. an error is detected with the UV-C light, triggering an error message and an end of the cycle (back to standby state). This image was created by turning off the UV-C light manually mid cycle.
In state B. there are no errors and the disinfection cycle runs to completion. A completion message is displayed to make clear the masks are clean and there were no errors. The cycle time here is chosen to give the mask a dose of ~3 J/cm^2, in compliance with standards laid out in the Germicidal UV-C section.
#include <LiquidCrystal.h>
unsigned long startCount;
unsigned long currentCount;
unsigned long cycleTime = 300000; //300 seconds to decontaminate
int red_led = 13, green_led = 11; //on+off indicator leds
int button = 12; //on+off button
int sensor_cc = 10;
int sensor_in_1 = A0, sensor_in_2 = A1; //sensor pins
const int rs = 7, en = 6, d4 = 5, d5 = 4, d6 = 3, d7 = 2; //lcd pins
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
// put your setup code here, to run once:
pinMode(red_led, OUTPUT);
pinMode(green_led, OUTPUT);
pinMode(button,INPUT);
pinMode(sensor_cc,OUTPUT);
pinMode(sensor_in_1,INPUT);
pinMode(sensor_in_2,INPUT);
digitalWrite(red_led,HIGH);
lcd.begin(16, 2);
// Print to the LCD.
lcd.print("Ready to");
lcd.setCursor(1,1);
lcd.print("Decontaminate");
}
int button_state;
int count = 0;
void measurement(){
int bias_1 = 7, bias_2 = 9;
unsigned long elapsedCount;
float remainingCount;
int sensor_1[500] = {};
int sensor_2[500] = {};
int sensor_diff[500] = {}; float sense_diff;
int voltage_1; int voltage_2;
digitalWrite(sensor_cc,HIGH);
lcd.clear();
for(int k=0;k<60;k++){
int counter = 0;
for(int j=0;j<500;j++){
delay(10);
currentCount = millis();
elapsedCount = currentCount-startCount;
remainingCount = (cycleTime-elapsedCount)/1000.0;
voltage_1 = analogRead(sensor_in_1);
voltage_2 = analogRead(sensor_in_2);
sensor_1[j] = voltage_1-bias_1;
sensor_2[j] = voltage_2-bias_2;
sensor_diff[j] = voltage_1-voltage_2;
if(counter==0){
lcd.clear();
lcd.print("Voltage:");
lcd.print(voltage_1);
lcd.setCursor(1,1);
lcd.print("Time:");
lcd.print(remainingCount);
lcd.print(" s");
}
counter = (counter+1)%10;
}
lcd.clear();
for(int j=0;j<500;j++){
sense_diff+=sensor_diff[j];
}
sense_diff = sense_diff/500.00; //take average of difference between two sensors to ensure the light is still operating correctly
if((sense_diff<1)){
lcd.print("UV-C light error");
return; //break the disenfection cycle if light error
}
}
digitalWrite(sensor_cc,LOW); //turn off sensors
lcd.clear();
lcd.print("Masks Clean");
}
int run_cycle() {
measurement();
delay(50);
return 1; //end this cycle and reset box to wait for next one.
}
void loop() {
// put your main code here, to run repeatedly:
startCount = millis();
button_state = digitalRead(button);
if(button_state==LOW){
count = count;
}
else{
count = (count+1)%2;
}
if(count==0){
digitalWrite(red_led,HIGH);
digitalWrite(green_led,LOW);
}
else{
digitalWrite(red_led,LOW);
digitalWrite(green_led,HIGH);
count = (count+run_cycle())%2;
}
// Serial.print(count);
delay(150);
}