Turn off I2C LED display using PIR sensor

Hi, I'm trying to make a motion-activated clock for my room using an RTC, a 1.2" LED display (I2C), a PIR sensor and an Arduino Uno. The idea is I want to wave my hand in front of the sensor, see the time for 5 seconds, then have the display go blank.

Using a breadboard, I wired the 5V line of the RTC and display to the 5V input on the Arduino. I did the same with the component ground lines into the Arduino GND, then the SCL lines into pin A5 and the SDA lines into pin A4.

I found code online that displayed the actual time to the LED using this wiring configuration.

Then, I added the PIR sensor by wiring its 5V in-line w/the common 5V line, its ground in-line with the common ground and its output to Arduino pin 12. I modified the code I found slightly (I'll post it below) to read the PIR input and use an "if" statement to only display the time when motion was sensed. I attached a wiring diagram. I apologize it's hand-drawn but maybe it helps visualize. The green rectangle w/red corners near the upper-right is a breadboard where the strips run horizontal.

The problem is that the display comes on as soon as the code is uploaded (which is what the original code was intended to do). When I run my hand past the sensor, the time updates, and a "blinkColon" command you'll see starts/stops the colon from blinking when motion is sensed. So I think the PIR sensor is wired correctly, but the LED display never turns off.

I then modified the code further w/an "else" statement to try & make the LED display blank a few seconds after motion was sensed. I couldn't get this version of the modified code to work either.

Next I tried adding a wire from Arduino pin 2 in hopes of using a "digitalWrite" command to drop voltage to the display. I changed the wiring as follows. Kept the 5V from the PIR and RTC in-line with the Arduino 5V, but separately put the display's 5V in-line with the pin 2 wire. This is represented by the dashed red lines in the wiring diagram. I left the SDA and SCL wiring the same, and the PIR output in pin 12, but the new wire from pin 2 did nothing.

I've only been able to display to the LED when all 5V lines are wired together, and I haven't found code to turn off the display when there's no motion. Please find the code as I modified it below. Nearly all of this code is someone else's, and it works very well before I added the PIR and modified it.

Any thoughts or input to help me move forward would be appreciated.

// Attempt at using a PIR to turn on/off 7-segment display
// Clock start time set manually at the very end of setup()

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <RTClib.h>
#include "Adafruit_LEDBackpack.h"


// Set to false to display time in 12 hour format, or true to use 24 hour:
#define TIME_24_HOUR      false

// I2C address of the display.  Stick with the default address of 0x70
// unless you've changed the address jumpers on the back of the display.
#define DISPLAY_ADDRESS   0x70


// Create display and DS1307 objects.  These are global variables that
// can be accessed from both the setup and loop function below.
Adafruit_7segment clockDisplay = Adafruit_7segment();
RTC_DS1307 rtc = RTC_DS1307();

// Keep track of the hours, minutes, seconds displayed by the clock.
// Start off at 0:00:00 as a signal that the time should be read from
// the DS1307 to initialize it.
int hours = 0;
int minutes = 0;
int seconds = 0;

int PIRsensor = 12;
// int sevenSegment = 2;
int sensorval = 0;

// Remember if the colon was drawn on the display so it can be blinked
// on and off every second.
bool blinkColon = false;


void setup() {
  // Setup function runs once at startup to initialize the display
  // and DS1307 clock.

  pinMode(PIRsensor, INPUT);
  // pinMode (sevenSegment, OUTPUT);
 
  // Setup Serial port to print debug output.
  Serial.begin(115200);
  Serial.println("Clock starting!");

// Setup the display.
  clockDisplay.begin(DISPLAY_ADDRESS);

  // Setup the DS1307 real-time clock.
  rtc.begin();

  // Set the DS1307 clock if it hasn't been set before.
  bool setClockTime = !rtc.isrunning();
  // Alternatively you can force the clock to be set again by
  // uncommenting this line:
  setClockTime = true;
  if (setClockTime) {
    Serial.println("Setting DS1307 time!");
    // This line sets the DS1307 time to the exact date and time the
    // sketch was compiled:
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    // Alternatively you can set the RTC with an explicit date & time, 
    // for example to set January 21, 2014 at 3am you would uncomment:
    rtc.adjust(DateTime(2019, 11, 29, 12, 18, 0));
  }
}

void loop() {
  // Loop function runs over and over again to implement the clock logic.
  
  // Check if it's the top of the hour and get a new time reading
  // from the DS1307.  This helps keep the clock accurate by fixing
  // any drift.
  
  if (minutes == 0) {
    // Get the time from the DS1307.
    DateTime now = rtc.now();
    // Print out the time for debug purposes:
    Serial.print("Read date & time from DS1307: ");
    Serial.print(now.year(), DEC);
    Serial.print('/');
    Serial.print(now.month(), DEC);
    Serial.print('/');
    Serial.print(now.day(), DEC);
    Serial.print(' ');
    Serial.print(now.hour(), DEC);
    Serial.print(':');
    Serial.print(now.minute(), DEC);
    Serial.print(':');
    Serial.print(now.second(), DEC);
    Serial.println();
    // Now set the hours and minutes.
    hours = now.hour();
    minutes = now.minute();
  }

  // Show the time on the display by turning it into a numeric
  // value, like 3:30 turns into 330, by multiplying the hour by
  // 100 and then adding the minutes.
  int displayValue = hours*100 + minutes;

  // Do 24 hour to 12 hour format conversion when required.
  if (!TIME_24_HOUR) {
    // Handle when hours are past 12 by subtracting 12 hours (1200 value).
    if (hours > 12) {
      displayValue -= 1200;
    }
    // Handle hour 0 (midnight) being shown as 12.
    else if (hours == 0) {
      displayValue += 1200;
    }
  }

  // Read the IR sensor to check for motion
  sensorval = digitalRead(PIRsensor);
  
  // If motion's detected, print the time to the display
  if (sensorval == HIGH) {

  // digitalWrite(sevenSegment, HIGH);

  // Now print the time value to the display.
  clockDisplay.print(displayValue, DEC);

  // Add zero padding when in 24 hour mode and it's midnight.
  // In this case the print function above won't have leading 0's
  // which can look confusing.  Go in and explicitly add these zeros.
  if (TIME_24_HOUR && hours == 0) {
    // Pad hour 0.
    clockDisplay.writeDigitNum(1, 0);
    // Also pad when the 10's minute is 0 and should be padded.
    if (minutes < 10) {
      clockDisplay.writeDigitNum(2, 0);
    }
  }

  // Blink the colon by flipping its value every loop iteration
  // (which happens every second).
  blinkColon = !blinkColon;
  clockDisplay.drawColon(blinkColon);

  // Now push out to the display the new values that were set above.
  clockDisplay.writeDisplay();

  // Close the motion-detection & display if statement
  }

  // Show the display as blank if the IR sensor
  // isn't activated
  else {
    // clockDisplay.writeDigitRaw(0, 0);
    // clockDisplay.writeDigitRaw(1, 0);
    // clockDisplay.writeDigitRaw(2, 0);
    // clockDisplay.writeDigitRaw(3, 0);
    clockDisplay.write(0x76);
  }

  // Pause for a second for time to elapse.  This value is in milliseconds
  // so 1000 milliseconds = 1 second.
  delay(1000);

  // Now increase the seconds by one.
  seconds += 1;
  
  // If the seconds go above 59 then the minutes should increase and
  // the seconds should wrap back to 0.
  if (seconds > 59) {
    seconds = 0;
    minutes += 1;
 
    // Again if the minutes go above 59 then the hour should increase and
    // the minutes should wrap back to 0.
    if (minutes > 59) {
      minutes = 0;
      hours += 1;
  
      // Note that when the minutes are 0 (i.e. it's the top of a new hour)
      // then the start of the loop will read the actual time from the DS1307
      // again.  Just to be safe though we'll also increment the hour and wrap
      // back to 0 if it goes above 23 (i.e. past midnight).
      if (hours > 23) {
        hours = 0;
      }
    }
  
  // Loop code is finished, it will jump back to the start of the loop
  // function again!
  } 
}

Attempting to turn off the power to the display is most unwise, especially as it uses I2C.

You need to find the code to turn the display off. I could be wrong, but suspect it is

 clockDisplay.clear();