-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinsoleuse.ino
70 lines (61 loc) · 1.6 KB
/
insoleuse.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <avr/pgmspace.h>
#include <LiquidCrystal.h>
const uint8_t relay_output = 9;
const uint8_t button_output = 8;
const uint8_t button_input = 7;
const uint8_t time_potentiometer = A0;
const PROGMEM char set_time_string[] = "UV Exposure Time";
const PROGMEM char exposure_string[] = "! UV Exposure !";
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
uint16_t timer = 0;
void setup() {
// put your setup code here, to run once:
lcd.begin(16, 2);
pinMode(relay_output, OUTPUT);
digitalWrite(relay_output, HIGH);
pinMode(button_input, INPUT_PULLUP);
pinMode(button_output, OUTPUT);
digitalWrite(button_output, LOW);
}
void update_timer() {
timer = analogRead(time_potentiometer) * .6;
}
void progmem_lcd_print(const char *str) {
char c = 0;
while ((c = (char)pgm_read_byte(str++)))
lcd.print(c);
}
void print_remaining_time() {
lcd.setCursor(11, 1);
lcd.print(timer);
lcd.setCursor(15, 1);
lcd.print("s");
}
void do_exposure() {
lcd.setCursor(0, 0);
progmem_lcd_print(exposure_string);
//lcd.print(exposure_string);
digitalWrite(relay_output, LOW);
while (timer) {
print_remaining_time();
timer--;
delay(1000);
}
digitalWrite(relay_output, HIGH);
}
void print_exposure_settings() {
lcd.setCursor(0, 0);
progmem_lcd_print(set_time_string);
//lcd.print(set_time_string);
print_remaining_time();
}
void loop() {
// put your main code here, to run repeatedly:
lcd.clear();
update_timer();
if (digitalRead(button_input) == LOW)
do_exposure();
else
print_exposure_settings();
delay(100);
}