atmega 2560 i2c issues

Hi

I am using atmega2560 pin20/21 for general purpose I/O. But to my surprise the output always stays high. Apparently no activity. What could be the reason?

gary36:
What could be the reason?

Maybe your code, but only you can see it right now :wink:

Here is the declaration

#define a 20
#define b 21
void setup()
{

pinMode(a, OUTPUT);
pinMode(b, OUTPUT);
}

void loop()
{
digitalWrite(a, LOW); // Pin stays always high
}

gary36:
digitalWrite(a, LOW); // Pin stays always high

What are you using to check it?

A Mega has a shipload of other pins.
Why are you trying to use the hardware I2C pins for anything else than I2C.
Note that the analogue pins can also be used as digital I/O.
Leo..

Issue resolved. Problem was in hardware. I2c pins were connected to EEPROM pulled to VCC.

gary36:
Issue resolved. Problem was in hardware. I2c pins were connected to EEPROM pulled to VCC.

No! The issue is now resolved. I have executed the following codes in my MEGA; the states of the DPin-20/21 are changing at 1-sec interval; the events have been observed by connecting 2.2k + LED circuit. Please, upload the sketch in your MEGA; if the pins are not toggling, then there is something wrong with the pins of your MEGA not for all MEGAs!

void setup() 
{
  Serial.begin(9600);
  pinMode(20, OUTPUT);
  pinMode(21, OUTPUT);
}
void loop() 
{
  digitalWrite(21, HIGH);
  delay(1000);
  digitalWrite(21, LOW);
  delay(1000);

}