// Send digital signal from motion detector // to the Atari joystick port pin 1 // via the Arduino digital pin 4 const int Digital_In = 2; // Digital in from motion sensor const int Digital_Out = 4; // Digital out to Atari int MotionState = LOW; // current state of pin void setup() { pinMode(Digital_In, INPUT); // Set pin 2 to input pinMode(Digital_Out, OUTPUT); // Set pin 4 to output pinMode(LED_BUILTIN, OUTPUT); // Set LED for feedback } void loop() { MotionState = digitalRead(Digital_In); // read new motion state if (MotionState == HIGH) // Motion detected? { digitalWrite(Digital_Out, HIGH); // send HIGH bit (1) to Atari digitalWrite(LED_BUILTIN, HIGH); // turn on the LED } else if (MotionState == LOW) // Motion not detected? { digitalWrite(Digital_Out, LOW); // send LOW bit (0) to Atari digitalWrite(LED_BUILTIN, LOW); // turn off the LED } }