In the code below if I use digitalRead(6) I can read the logic level on my PortD Pin6. If I use the Led = PORTD & B11000000 statement I do not get bit6 wiggling as I'd expect.
What am I doing wrong?
void setup()
{
Serial.begin(9600);
// prints title with ending line break
Serial.println("Setup starting");
// The Data Direction Register of Port D, don't touch the
// lower two bits which are serial IO
DDRD = DDRD | B00111100 ;
}
void loop()
{
int i = 0 ;
int iLed = 0 ;
while (true) {
I take it by "wiggling" you mean "toggling" ie 1 becomes 0 and 0 becomes 1
You can do this with an AND operation, because only 1 and 1 = 1 , so as soon as you get a 0 in there, the output will always be 0, it will never flip back to 1 again.
But, as seen in Post before: you can write to PIN, and the Bits which are written to "1" change their state.
Also you can write with a PORTx pin command, and if the pin is in the input mode (via DDRx pin) and it will turn on (if 1) or off (if 0) the internal pull-up for that pin.