Initial working Telegram bot, LDR and LED
This commit is contained in:
23
Arduino/Arduino.ino
Executable file
23
Arduino/Arduino.ino
Executable file
@ -0,0 +1,23 @@
|
||||
#define LEDPIN 8
|
||||
|
||||
String incomingString;
|
||||
|
||||
void setup() {
|
||||
pinMode(LEDPIN, OUTPUT);
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (Serial.available() > 0) {
|
||||
char cmd = Serial.read();
|
||||
if (cmd == 'O') {
|
||||
digitalWrite(LEDPIN, HIGH); // Open
|
||||
} else if (cmd == 'C') {
|
||||
digitalWrite(LEDPIN, LOW); // Close
|
||||
} else if (cmd == 'R') {
|
||||
int ldrValue = analogRead(A0);
|
||||
Serial.println(ldrValue);
|
||||
}
|
||||
}
|
||||
delay(50);
|
||||
}
|
16
Arduino/LDRtest/LDRtest.ino
Normal file
16
Arduino/LDRtest/LDRtest.ino
Normal file
@ -0,0 +1,16 @@
|
||||
/* LDR test measuring with A0 in middle of 10k Ohm resistor and LDR
|
||||
* +5V ---[ LDR ]---+---[ Resistor ]--- GND
|
||||
|
|
||||
Analog A0
|
||||
*/
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
int value = analogRead(A0); // Reads value between 0 and 1023
|
||||
Serial.println(value);
|
||||
delay(500);
|
||||
}
|
||||
|
Reference in New Issue
Block a user