Go Down

Topic: atmega 2560 i2c issues (Read 115 times) previous topic - next topic

gary36

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?

neiklot

What could be the reason?
Maybe your code, but only you can see it right now ;)


gary36

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
}

neiklot

digitalWrite(a, LOW); // Pin stays always high
What are you using to check it?


Wawa

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..

gary36

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

GolamMostafa

#6
Mar 25, 2019, 03:47 pm Last Edit: Mar 25, 2019, 03:49 pm by GolamMostafa
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!
Code: [Select]
void setup()
{
  Serial.begin(9600);
  pinMode(20, OUTPUT);
  pinMode(21, OUTPUT);
}
void loop()
{
  digitalWrite(21, HIGH);
  delay(1000);
  digitalWrite(21, LOW);
  delay(1000);

}

Go Up