// A test for the Discord channel.
// Original: https://wokwi.com/projects/432367544589072385
// Removed everything except the open drain output.
// Pin 2 = PD2 (PortD, bit 2)
// Reference: https://docs.arduino.cc/retired/hacking/hardware/PinMapping168/
//
// Minimal code. It seems to work.
// Specific order to avoid a spike.
// First the pin is set as input,
// then the pullup resistor is enabled.
#define lineRelease() \
DDRD &= ~(1<<PD2); \
PORTD |= (1<<PD2);
// Very specific order to avoid a spike.
// First the bit for the output level is set,
// then the pin is turned into a output.
#define lineLow() \
PORTD &= ~(1<<PD2); \
DDRD |= (1<<PD2);
void setup() {
Serial.begin(115200);
// At power on, all pins are input.
// But it does not hurt to set it again.
DDRD &= ~(1<<PD2);
// Enable pullup
PORTD |= (1<<PD2);
}
void loop()
{
lineLow();
delay(500);
lineRelease();
delay(500);
}