ArduinoGeneral

Pin mapping differences between Atmega 328 (UNO) and 32U4 (XBoard) chipsets?

userHead Account cancelled 2013-06-28 07:30:20 3185 Views0 Replies
Does anyone know how to revise a sketch that addresses the analog pins as digital pins by adding +14 to the pin number from an Atmega 328 chipset (what the sketch was originally written for) to an XBoard 32U4 chipset? The code in question is at the bottom of my post in case it helps. Basically I'm trying to use Analog pins 2 and 3 (or any two analog pins for that matter) to read open or closed from some contact sensors. I'm very new to the Arduino world but loving it so far, just frustrating at times so figured I'd try reaching out to people who are way smarter than me. Jose has been awesome at helping but I don't want to keep taking up his time if I don't have to. Any thoughts on how to make this work would be greatly appreciated.

Orcrist13

void configureStatusPin(int pinNumber)
{
#if defined(STATUS_STRATEGY_3VCLOSED_5VOPENED) || defined(STATUS_STRATEGY_5VCLOSED_3VOPENED)
pinMode(pinNumber, INPUT);
#elif defined(STATUS_STRATEGY_NORMALLY_CLOSED) || defined(STATUS_STRATEGY_NORMALLY_OPENED)
pinMode(pinNumber+14, INPUT_PULLUP); // addressing analog pins as digital pins (+14)
#endif
}

//----------------------------------------------------------------------------------------------------
boolean isOpen(int pinNumber)
{
#if defined(STATUS_STRATEGY_3VCLOSED_5VOPENED) || defined(STATUS_STRATEGY_5VCLOSED_3VOPENED)
int status = analogRead(pinNumber);
#elif defined(STATUS_STRATEGY_NORMALLY_CLOSED) || defined(STATUS_STRATEGY_NORMALLY_OPENED)
int status = digitalRead(pinNumber+14); // addressing analog pins as digital pins (+14)
#endif[/size][/size]