-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patholfactory_display_atomizer_code.ino
More file actions
65 lines (46 loc) · 1.34 KB
/
olfactory_display_atomizer_code.ino
File metadata and controls
65 lines (46 loc) · 1.34 KB
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
int Fan = 10; // servo pin
int ScentOne = 3; // atomizer 1 pin (with lavender essential oil)
int ScentTwo = 0; // atomizer 2 pin (with orange essential oil)
void setup() {
// Allow allocation of all timers
// ESP32PWM::allocateTimer(0);
// ESP32PWM::allocateTimer(1);
// ESP32PWM::allocateTimer(2);
// ESP32PWM::allocateTimer(3);
Serial.begin(460800);
// pwm.attachPin(APin, freq, 10); // 1KHz 10 bits - commented out for now
pinMode(Fan, OUTPUT);
pinMode(ScentOne, OUTPUT);
pinMode(ScentTwo, OUTPUT);
Serial.println("Smells!");
digitalWrite(Fan, HIGH);
}
void loop() {
// Check if data is available
if (Serial.available() > 0) {
String command = Serial.readStringUntil('\n');
command.trim();
// if (command == "FAN") {
// Serial.println("Action from Unity!");
// digitalWrite(Fan, HIGH);
// delay(3000);
// digitalWrite(Fan, LOW);
// }
if (command == "ScentOne") {
Serial.println("Action from Unity!");
digitalWrite(ScentOne, HIGH);
delay(6000);
digitalWrite(ScentOne, LOW);
}
if (command == "ScentTwo") {
Serial.println("Action from Unity!");
digitalWrite(ScentTwo, HIGH);
delay(6000);
digitalWrite(ScentTwo, LOW);
}
else {
Serial.print("Unknown command received: ");
Serial.println(command);
}
}
}