You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Final Code/IDE_FINAL_all_/IDE_FINAL_all_.ino
+28-5Lines changed: 28 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -6,10 +6,10 @@
6
6
#include<Servo.h>//only for Servo
7
7
8
8
9
-
char SSID[] = ""; // ENTER NETWORK SSID & PASS
10
-
char PASS[] = "";
9
+
char SSID[] = ""; // ENTER NETWORK SSID & PASS
10
+
char PASS[] = "";
11
11
12
-
#defineBOTtoken""//YOUR BOT TOKEN
12
+
#defineBOTtoken""//YOUR BOT TOKEN
13
13
#defineLEDPIN2//YOUR PIN NUMBER ON BOARD
14
14
#defineDHTPIN5
15
15
#defineLDRPIN A0
@@ -113,6 +113,29 @@ void loop() {
113
113
Serial.println(pulse); // will print the value of the pulse in the serial monitor
114
114
}
115
115
116
+
117
+
if (bot.messages[i].text == "/FADE")
118
+
{
119
+
120
+
pulse = 0;
121
+
while (pulse < 255)
122
+
{
123
+
pulse = pulse + 40;
124
+
analogWrite(LEDPIN, pulse);
125
+
delay(300);
126
+
}
127
+
while (pulse > 0)
128
+
{
129
+
pulse = pulse - 40;
130
+
analogWrite(LEDPIN, pulse);
131
+
delay(300);
132
+
}
133
+
pulse = 0;
134
+
135
+
bot.sendMessage(bot.messages[i].chat_id,"LED has faded!", ""); // The bot will notifiy you that it is turned off
136
+
137
+
138
+
}
116
139
if (bot.messages[i].text == "/TEMP")
117
140
bot.sendMessage(bot.messages[i].chat_id, "Temperature is " + String(myTemperature) + "*C", "");
118
141
@@ -141,7 +164,7 @@ void loop() {
141
164
}
142
165
143
166
if (bot.messages[i].text == "/OFFservo") {
144
-
myservo.write(0); // sets the servo position
167
+
myservo.detach(); // sets the servo position
145
168
bot.sendMessage(bot.messages[i].chat_id, "Servo is OFF", "");
146
169
}
147
170
@@ -160,7 +183,7 @@ void loop() {
160
183
161
184
if (bot.messages[i].text == "help")
162
185
{
163
-
bot.sendMessage(bot.messages[i].chat_id, "Hello ASSEMBLY attendee! I am your bot! \n Use following commands: \n /ON - turns on the LED connected \n /OFF - turns off LED connected \n /TEMP - gives temperature \n /HUMID - gives humidity \n /Increase - increases LED brightness \n /Decrease - decreases LED brightness \n /ONservo - pushes servo out \n /OFFservo - pulls servo back \n /TRYservo - test servo", "");
186
+
bot.sendMessage(bot.messages[i].chat_id, "Hello ASSEMBLY attendee! I am your bot! \n Use following commands: \n /ON - turns on the LED connected \n /OFF - turns off LED connected \n /TEMP - gives temperature \n /HUMID - gives humidity \n /Increase - increases LED brightness \n /Decrease - decreases LED brightness \n /FADE - shows led fading \n/ONservo - pushes servo out \n /OFFservo - pulls servo back \n /TRYservo - test servo", "");
0 commit comments