#define MovementSensorPin 5 int motionDetected = LOW; // Default no motion Detected int motionDetectedAmount = 0; // Amount of motion detected count int motionValue = 0; void initMovementSensor() { pinMode(MovementSensorPin, INPUT); } void handleMotionSensor() { char deviceUUID[10] = "a328-4229"; motionValue = digitalRead(MovementSensorPin); // Detected Movement if (motionValue == HIGH) { if (motionDetected == LOW) { motionDetected = HIGH; char command[20] = "movement_data"; char dataBuffer[40] = "detected_movement"; sendSerialCommand(deviceUUID, command, dataBuffer); } } else { if(motionDetected == HIGH) { motionDetected = LOW; char command[20] = "movement_data"; char dataBuffer[40] = "no_movement"; sendSerialCommand(deviceUUID, command, dataBuffer); } } }