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:
- Wired the digital pin 0 to the analog one A15
- 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));
}
- 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?