PORTD writing

Hi,

I was wondering if I can write a value to PORTD with something like:

PORTD=myVar

As I understand I have to unplug my Arduino from USB so I don't mess with TX and RX signals on pin1 and pin2 of PORTD, if that's the case, will a simple instruction like that work?

I'm trying to sense temperature with a LM35 sensor and then write that value (converted from 10-bit length to 8-bit) to PORTD so I can interface it with another circuit. Is that possible?

Thanks, Felix.

Yeah, that’ll work fine. If you don’t need to bottom two bits, you could write a 6-bit value like this:

tmp = PORTD & 0x03;  // Grab TX and RX bits
PORTD = tmp | (myByte << 2);  //  Write your 6 bits out.

I’m thinking of doing something like this so I don’t have to unplug for the time being. It would have been nice if they would have left PORTD completely alone so you’d have at least one whole port that was “naked”.