digitalWrite(0, LOW) is pushing a HIGH amplitude signal

Hi folks,

I'm using the Mega 2560 and trying to set the amplitude of the digital pin 0 to LOW (amplitude == 0), and used the following methods for testing so:

  1. Wired the digital pin 0 to the analog one A15
  2. Compiled and uploaded the following code to the MCU:
void setup()
{
 Serial.begin(9600);
 pinMode(0, OUTPUT);
 digitalWrite(0, LOW);
 pinMode(A15, INPUT);
}
void loop()
{
 Serial.print("BUZZER OF DIGITAL 0 LOW VAL = ");
 Serial.println(analogRead(A15));
}
  1. Looked at the console and found the following repeated message:

BUZZER OF DIGITAL 0 LOW VAL = 1023

It's known that the constants:
HIGH = 1023
LOW = 0

The problem here is that the digitalWrite() method is outputting the opposite signal HIGH to the value that was specified within the code which is LOW.

Any idea?

Perhaps because pin 0 is a serial comms pin, and you are using Serial.

Try pin 2?

Willpatel_Kendmirez:
Perhaps because pin 0 is a serial comms pin, and you are using Serial.

Try pin 2?

You're right, I forgot that the 0/1 digital pin ports are used for serial communication RX/TX. Going to start wiring my digital I/O wiring from the third pin. Thanks a bunch for the information. Cheers. :wink: