diff --git a/docs/configuration/module-config/serial.mdx b/docs/configuration/module-config/serial.mdx index 52ea28c1..6cb228fb 100644 --- a/docs/configuration/module-config/serial.mdx +++ b/docs/configuration/module-config/serial.mdx @@ -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 + } +} +``` +```