24 lines
446 B
C++
Executable File
24 lines
446 B
C++
Executable File
#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);
|
|
}
|