Voltage Spikes on Digital Pin

This is the first time that I have pointed an oscilloscope probe at a microprocessor (or anything else for that matter) so I am sure that I am missing some fundamental skills in this area. I am playing around with an ATmega328P and have connected Digital Pin 5 to a bipolar transistor switch which in turn is driving a MOSFET switch. The MOSFET switch is controlling power to an ultrasonic sensor and radio device. I am probing levels on DP5 and the output of the MOSFET (Vout). I am observing the DP5 output going high for about 1 second and then going low, all as intended by the sketch. It is what’s happening for about 1.5 seconds prior to DP5 going fully high that has me stumped. You can see on the DSO trace that there is a succession of spikes uniformly spaced at 68 millisecond intervals ahead of DP5 going high. While these spikes are occurring the MOSFET output (Vout) is ramping upward in a spikey manner and seemingly in sympathy with the DP5 activity to about 2.5 volts before switching on fully. There is a 4.7k ohm pull-down resistor on DP5.

The sample on the DSO traces has a supply of 4.0 volts. I get similar results for supply up to 5.0 volts. Below 4.0 volts the device becomes unstable with the DP5 pin hanging in a high state after a few cycles of loop(). I have set the ATmega328P up with a 16 MHz oscillator and the normal compliment of capacitors.

Does anyone recognise a pattern in the DSO traces that could explain what is going on here?

Many thanks for your feedback. In a way I am relieved by your comment that something is wrong with my project. Being a novice in this area I was not certain that something was indeed wrong based on those traces. I interpret from the remainder of your post that there could be many explanations for what is observed on the traces, which in itself is useful information for me if I am interpreting you correctly.

I certainly wasn’t trying to hide information from anyone. I thought that it might be expedient to filter out if there was a problem at all, or if the issue stuck out like the proverbials, before I swamp the thread with what could have been unnecessary detail. Now that you have clarified that there is definitely a problem to be addressed here I will compile the additional information you have suggested, and post this.

Wow. I’ve really stepped on a hornets nest here. I am so sorry you have had such bad experiences with people not following strict protocol. I don’t think I’ll now progress to stage 2 of my errant troubleshooting in view of the flare-up arising from stage 1. At least you inadvertently answered my stage 1 question which sought to establish if I had a problem or not, and for that I thank you.

@Delta_G: I try to avoid posting information from various reasons. I am ashamed for low quality code when it is in the "testing" phase. Also I doubt anyone will read 1000+ lines of code including 10 libraries "found somewhere on internet" with cryptic comments everywhere. So I try to remove as much unnecessary code as possible and add comments to make it clear. Similar goes for circuit - if I have a schematics it is hard to understand unless you remember what I meant when I draw it. I need to redraw it cleanly before presentation. And the physical circuit is similar mess, often on more than one breadboard, sometimes with other unrelated projects on other part of the breadboard ;-). There is no chance to track jumper wires from a photo.
Cleaning a project to be "worth presenting" takes a lot of work. While doing so, I often find the bug myself. But it is tempting to ask without showing anything, skipping all the boring work - maybe someone guesses the answer anyway.

@Timbergetter: Please, show what was causing this, I am curious. My guess is a SW bug.

Delta_G:
(...)
And now we get the truth. Lazy. Yet you expect others to jump up and help you for free. That's pretty despicable if you ask me. To put the work on the volunteers.

Or maybe you just waste someone else's time. I mean why should you care, it's not like it is YOUR time right? Who cares what you do to other people. Screw them, right? They're only offering free help to you, why should you pay them any respect.

You will never understand it when you don't want to understand it. I don't want to waste others time. THIS is the reason I do NOT post a poor code with tons of irrelevant stuff. And yes, I think 1000 lines of code written by someone else with no or cryptic comments is a lot - I rarely read such code because I consider it waste of my time. I don't expect others would read my code if presented in such way. The same is true for schematics - I can read my handwriting well. I don't expect it will be easy for you to read and follow my quickly sketched schematics. If I do it for others I try to do it nicely and precisely and often need more than one iteration.

I think many people feel it the same way. They try to provide information that they believe is important and avoid irrelevant stuff. If you think not enough information was provided you may ask - or ignore the thread at all. I don't see how not providing (possibly boring or misleading information) forces other to help me.