-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.ino
66 lines (55 loc) · 1.37 KB
/
test.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
#define HalogenPin 14 // Send the value from the potentiometer (P1.6)
#define FanPowerPin 12 // Turn on and off the fan (P2.4)
#define LEDPin 10 // To control the LED(P2.2)
//#define OnePin 2
//#define TwoPin 3
//#define ThreePin 4
//#define FourPin 5
//#define FivePin 8
//#define SixPin 9
void setup() {
Serial.begin(9600); //Start data transmission
pinMode(HalogenPin, OUTPUT); //Set HalogenPin as output
pinMode(FanPowerPin, OUTPUT); //Set FanPowerPin as output
pinMode(LEDPin, OUTPUT); //Set LEDPin as output
UnpowerFan();
UnpowerLed();
UnpowerHalogen();
}
void loop() {
int num;
if (Serial.available() > 0) {
num = Serial.parseInt();
if (num==1 ) {
PowerFan();
} else if (num==2) {
UnpowerFan();
} else if (num==3) {
PowerLed();
} else if (num==4) {
UnpowerLed();
} else if (num==5) {
PowerHalogen();
} else if (num==6) {
UnpowerHalogen();
}
}
}
void PowerFan() {
digitalWrite(FanPowerPin, HIGH);
}
void UnpowerFan() {
digitalWrite(FanPowerPin, LOW);
}
void PowerLed() {
digitalWrite(LEDPin, HIGH);
}
void UnpowerLed() {
digitalWrite(LEDPin, LOW);
}
void PowerHalogen() {
analogWrite(HalogenPin, 0);
}
void UnpowerHalogen() {
analogWrite(HalogenPin, 255);
}