Looking at the schematic for ATMEGA1280-16AU I see the following:
Digital Pin 42 PL7
Digital Pin 41 PL6
Digital Pin 40 PL5(OC5C) PWM
Digital Pin 39 PL4(OC5B) PWM
Digital Pin 38 PL3(OC5A) PWM
Digital Pin 37 PL2(T5)
Digital Pin 36 PL1(ICP5)
Digital Pin 35 PL0(ICP4)
[? What do the values in parens (OC5P, OC5B, etc.) mean?]
From reading the "Port Registers" section at arduino.cc, I interpret this to be the pin map for Port L of the Mega. If I have 8 digital inputs (switches) hooked up to pins 35 through 42, I believe I can:
a. Read individual pins:
bitVal = digitalRead(37) // Read Pin 37/ PL2
bitVal = digitalRead(PL2) // Same thing - right?
b. Read multiple pins:
byteVal = digitalRead(PL) // Reads all 8 pins (35 thru 42) into one byte ??
Is this correct? I want to read in 8 digital pins at once, process, then output to 8 different digital pins at once.
From reading the "Port Registers" section at arduino.cc, I interpret this to be the pin map for Port L of the Mega. If I have 8 digital inputs (switches) hooked up to pins 35 through 42, I believe I can:
a. Read individual pins:
bitVal = digitalRead(37) // Read Pin 37/ PL2
bitVal = digitalRead(PL2) // Same thing - right?
No, you can't use PLx with a digitalRead command
b. Read multiple pins:
byteVal = digitalRead(PL) // Reads all 8 pins (35 thru 42) into one byte ??
No you can't use PL in a digitalRead command. However you can
use direct port commands to do the same thing: byteVal =PINL; You can also write all 8 bits in a
port at the same time using the PORTL = 0xff; or any other 8 bit value.
Here is a reference to direct port access commands: