Well, the thing is that digitalRead(PIND) is not merely a simple assignment. "PIND" is itself a "C" macro which (as I understand it, not having used it) used as an argument, reads the value of that register into a byte - which is apparently what you really intend to do. "digitalRead" however, is a function especially designed to take an index to an Arduino "pin number", figure out which port is being referenced, read from that port and select the corresponding bit and return the value of that bit only as a numeric value.digitalWrite(PORTB, x) would perform a similar action, interpreting "x" as a Boolean value (either zero or non-zero) and writing it to a single port bit which it has determined from the value read from PORTB. By no means the same as a simple assignment to PORTB as in Code: [Select]PORTB = x;.
PORTB = x;
I cannot simply use digitalRead(PIND)?
x = digitalRead(PIND); //PIND reads PORT D pinsdigitalWrite(PORTB, x);
x = PIND; // PortRead(PIND), sort ofPORTB = x; // PortWrite(PORTB, x)
Except that both PortNames and PinNumbers are not actually implemented as "types" that the compiler understands; they both just look like integers.
y = PORTB = x;
"PORTD" and "DDRD" are however not numbers at all, they are a macro which translates into assembler instructions to either read or write to the given I/O register in the chip
x = * ((volatile byte *)(0x25))
#define PORTB _SFR_IO8(0x05) // iom328p.h#define _SFR_IO8(io_addr) ((io_addr) + __SFR_OFFSET) // sfr_defs.h#define __SFR_OFFSET 0x20 // sfr_defs.h
I need to get it so I can read 16 pin inputs, but read it really fast.
If all 4 of the dip switches are on HIGH, all 4 Heathkit LEDs are HIGH (on). However, if I turn any number of the dip switches to the LOW position, all of the LEDs go LOW (off).
Yes and no. "I/O registers" on an AVR appear in the same memory space and map as RAM, so the the PORTD and DDRD and so on in fact resolve to dereferences of pointers to bytes