Hello. I am trying to use interrupt 0 on Digital Pin No. 21 ( SCL/INT0 ). The interrupt worked fine, however, I need the input to behave as INPUT instead of INPUT_PULLUP. I declared pinMode(21, INPUT) in setup() but when I measure the voltage between pin 21 and GND it still shows 5V. How can I configure it as normal INPUT?
You have some I2C device connected to SCL? Which version of the Mega are you using?
There are pullups on SDA and SCL in the original design.
Mega 2560 R3. I see. So there is no way to make it as a normal INPUT? I am planning to use external pull down to get PNP signal from optocoupler output.
What happend to all the other pins?
There should be at least one pin free that is useable as pinchange or external interrupt.
Why sacrifice I2C?
So use the external pulldown. You don't need much to overcome the board's 10K pullup.
Or use an Opto with NPN output, let it pull down when active, and test for a Low instead of a High.
NPN opto is good idea but I need time to get it. To overcome the 10k, can you please draw me a simple circuit to guide me? Sorry, I am from programming background and I don't have much Electrical knowledge. Thanks.