Alright, here is a simple program that isn't working as it should and I have no idea why.

I have hooked a motor to an H-Bridge and placed pins 5 (PD3) and 6 (PD4) to my ATmega328 (from the UNO) to the logic of the H-Bridge and placed pin 3 (PD1) to the enable of the H-Bridge. Now, the idea is to PWM the enable of the H-Bridge while the Arduino pins 5 & 6 control the direction the motor will spin.

The PWM works fine (the motor spins faster and slower over time), but it spins only in one direction and I have no idea why. Here is a simple program that I made for testing:

Is it a bought H Bridge motor driver, or one you've made yourself?What sort of motors are you using? Voltage, current rating etc?Also, might help if you post a schematic of your circuitry.

I'm still new to all this myself to be honest, but providing the above information will make it easier for folk to help...

One thing I would say, have you tested your setup with a simpler program e.g. one that just brings the logic levels high and low for a period of time? Then you would know if the problem is in the program or in the wiring...

I know the problem isn't my H-Bridge, because when I physically put the bridge logic to HIGH and LOW, then the motors spin in a certain direction and when I reverse to LOW and HIGH the motors spin in the opposite direction (as it's suppose to). The problem is in the ATmega328 isn't sending the signal as I would expect and want to know if it's a coding error.

I guess I am wondering which side of the zero point the issue is happening on.

I had something like this happen to me once on a 2n3055 TO-3 transistor h-bridge I had made, but that was due to a faulty alligator clip (needed clips to connect the collectors together); this isn't the issue in your case, though - obviously...

I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

Yes, you were very much correct; the problem was my pins. apparently when declaring: pinMode(5, OUTPUT);the 5 refers to PD5 and not pin 5.

I'm shocked I made it this far without knowing this. Perhaps I did know it in the past and am just too stupid to remember. Either way, thank you very much for the help.

Glad you sorted it out, but I wasn't aware that the labels on the diagram had anything to do with the code; from your description, you seemed fairly confident it was the code, not the hardware, so I made the (wrong) assumption that your code was configure properly for the hardware, and the hardware was hooked up properly. Hmm - next time you post something like this, you should post your -entire- schematic (all parts and connections) included, along with your complete code (which you did); it would save all of us time.

I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.