digitalWrite for PORTB (Atmega 328)

I am using an Atmega 328 and version 1.0.2 IDE but can not make digitalWrite work for pin 14 (or 15,16 etc). The below code works fine and blinks but if I use the commented out code instead of the existing code I get no blink? I could not find any documented prohibition on using digitalWrite with PORTB. I even replaced the variable led with 14 but still no blink. I know the circuitry is ok because the register oriented code works. (I even wrote my own 4 character 7 segment display and it works fine using registers, just can not use pinMode and digitalWrite)

#define SRC_A 14
#define MS 500

int led = 14;

void setup()
{
DDRB = 0x01; // bit 0 output
PORTB = 0x00;
//pinMode(led, OUTPUT); //or: pinMode(14, OUTPUT);
}
void loop()
{
//digitalWrite(led, HIGH); // or: digitalWrite(14, HIGH);
PORTB = 0x01;
delay(MS);
//digitalWrite(led, LOW); // or: digitalWrite(14, LOW);
PORTB = 0x00;
delay(MS);
}

I am a bit confused as to what actually does not work.
Can you post the code that does not work and use the correct code tags when you do. It is the # icon in the reply box.

Sorry but I do not know what you mean by code tags (I am new and this is my first post). The code that fails (fails to blink) is:

#define MS 500

int led = 14;

void setup()
{
pinMode(led, OUTPUT);
}
void loop()
{
digitalWrite(led, HIGH); // no LED output
delay(MS);
digitalWrite(led, LOW);
delay(MS);
}

I know that is essentially the standard blink code but it does NOT blink! No error messages, no upload problems just no blink!

Sorry but I do not know what you mean by code tags (I am new and this is my first post).

The top post in this section says Read this before posting. That tells you all about how to post code.
When you post it correctly people can copy your code and try it out. It looks fine so I would like to try it to attemp to help you, please help me to help you.

Thank you for your quick response. Again, the code is below.
NOTE I changed the int led = 14 to int led = 13 and the on board LED blinked fine.
It simply will not blink with pin 14 of register B using digitalWrite().

#define MS 	500

int led = 14;

void setup()
{
pinMode(led, OUTPUT);
}
void loop()
{
digitalWrite(led, HIGH);  // no LED output
delay(MS);
digitalWrite(led, LOW);
delay(MS);
}

Do you mean pin 14 on the chip? That is called D8 in the IDE. Change 14 to 8 and see what happens.

If you don't mean that, what do you mean? There is no pin labelled 14 on the Arduino board,

Thanks for posting the code. I tried it exactly as posted and it flashes fine.
I am using an Arduino Uno.
Pin 14 is analogue pin 0, are you connecting your LED and resistor to this pin?

... but can not make digitalWrite work for pin 14 (or 15,16 etc).

I think he's referring to the chip pins since PORTB worked, and that is what pin 14 is on.

To all who so kindly responded. I have found the problem. In my ignorance I assumed the pin number for digitalWrite was the chip (Atmega 328) pin number. I now know that it is for the BOARD pin numbers. Since my board is a Boarduino, which apparently has different pin numbers for the digitalWrite and pinMode which are board specific the compiled code was wrong. I got the register information directly from Atmega documentation for the chip, which is why the register referenced code worked.

In my defense I am very new to these platforms and I have not coded for hardware for about thirty years so please excuse my blunder. What would be nice if someone could refer me to some documentation that separates the board specific code from the underlying C, and C++ code. That way I could avoid those pitfalls.

Good to know that even with different pin (board) numbers the basic chip specific code works great.

Again thanks to all.

so please excuse my blunder.

No problem.

refer me to some documentation that separates the board specific code from the underlying C, and C++ code.

Try this for the pin numbers:-
http://www.arduino.cc/en/Hacking/PinMapping168

Basically there are a load of functions that the compiler pulls in that relate to the board and the pin numbers. These are mainly inside the Arduino application, you can open this up and have a look at them, but it makes heavy reading as it is just a load of defines.

Since my board is a Boarduino, which apparently has different pin numbers for the digitalWrite and pinMode

You sure of that? It is not something I remember any one else reporting.