-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathControlBox.ino
More file actions
97 lines (85 loc) · 2.04 KB
/
ControlBox.ino
File metadata and controls
97 lines (85 loc) · 2.04 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// DeskControlHub
// Code By Ilastrait
// Feel Free To Edit According To Usecase
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Set the LCD address to 0x27 for a 16 chars and 2 line display
// Change according to the ld you are using
LiquidCrystal_I2C lcd(0x27, 16, 2);
// Sensor pin info, chasnge according to the pins you have connected your equipment to
/*
* ts1 - Touch Switch 1
* ts2 - Touch Switch 2
* relay1 - Relay 1 signal pin
* relay2 - Relayu 2 signal pin
* switch1 - Arbitary variable to store switch 1 pin value
* switch2 - Arbitary variable to store switch 2 pin value
*/
int ts1 = 11;
int ts2 = 9;
int relay1 = 2;
int relay2 = 4;
int switch1=0;
int switch2=0;
void setup()
{
Serial.begin(9600);
lcd.begin();
lcd.backlight();
pinMode(ts1, INPUT);
pinMode(ts2, INPUT);
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
lcd.setCursor(0,0);
lcd.print("HEAD Light : ");
lcd.setCursor(0,1);
lcd.print("FOOT Light : ");
}
void loop()
{
switch1 = digitalRead(ts1);
switch2 = digitalRead(ts2);
if(switch1==1)
{
if(switch2==1)
{
digitalWrite(relay1, LOW);
digitalWrite(relay2, LOW);
lcd.setCursor(13,0);
lcd.print("LIT");
lcd.setCursor(13,1);
lcd.print("LIT");
}
else
{
digitalWrite(relay1, LOW);
digitalWrite(relay2, HIGH);
lcd.setCursor(13,0);
lcd.print("LIT");
lcd.setCursor(13,1);
lcd.print("OFF");
}
}
else
{
if(switch2==1)
{
digitalWrite(relay1, HIGH);
digitalWrite(relay2, LOW);
lcd.setCursor(13,0);
lcd.print("OFF");
lcd.setCursor(13,1);
lcd.print("LIT");
}
else
{
digitalWrite(relay1, HIGH);
digitalWrite(relay2, HIGH);
lcd.setCursor(13,0);
lcd.print("OFF");
lcd.setCursor(13,1);
lcd.print("OFF");
}
}
}
// Code By Ilastrait