mirror of
https://github.com/meshtastic/meshtastic.git
synced 2025-01-29 14:51:50 -08:00
Update serial.mdx
add arduino .ino code tested with arduini mini pro with pir sensor connected to pin 2
This commit is contained in:
parent
9ed7799ab8
commit
d4bb6ef727
|
@ -245,3 +245,30 @@ while True:
|
|||
time.sleep(30)
|
||||
time.sleep(0.5)
|
||||
```
|
||||
|
||||
#### Circuit .ino Code
|
||||
|
||||
```
|
||||
int LED = 13; // the pin that the LED is atteched to
|
||||
int PIR = 2; // the pin that the sensor is atteched to
|
||||
|
||||
void setup() {
|
||||
pinMode(LED, OUTPUT); // initalize LED as an output
|
||||
pinMode(PIR, INPUT); // initialize sensor as an input
|
||||
Serial.begin(9600); // initialize serial
|
||||
}
|
||||
|
||||
void loop(){
|
||||
if (digitalRead(PIR) == HIGH) { // check if the sensor is HIGH
|
||||
digitalWrite(LED, HIGH); // turn LED ON
|
||||
Serial.write(":Motion!:");
|
||||
delay(10000); // delay 100 milliseconds
|
||||
}
|
||||
else {
|
||||
digitalWrite(LED, LOW); // turn LED OFF
|
||||
Serial.write("Motion stopped!");
|
||||
delay(10000); // delay 100 milliseconds
|
||||
}
|
||||
}
|
||||
```
|
||||
```
|
||||
|
|
Loading…
Reference in a new issue