PINS 14-19 of Arduino Mega usable for Digital or Analog Output ?

hi all,

my goal is to control bistable Relais by digital or analog Output (HIGH,LOW).
Above Code works well with default digital pins.

But all pins except 14-19 of Arduino mega 2560 are in use by LED or Servo
on this Project !

In the pinouts i find that pins 14-19 are rx/tx pins and digital pins both.
Tried to use them with digitalWrite and analogWrite
but seems not to work ...
here parts of code

#define ANZ_RELAIS_PINS 6
.
.
uint8_t relais_pins[ANZ_RELAIS_PINS] = {14,15,16,17,18,19};
.
.
  //- Pins fuer Relais initialisieren
  for(i=0;i < ANZ_RELAIS_PINS;i++)
  {
    pinMode( relais_pins[i],OUTPUT);
    send_pulse(relais_pins[i]);
  }
.
.
void send_pulse(int pin)
{
  //- mer mache das jetzt einfach auf nen digitalen PIN..weil bei den bistab.Relais ein FlipFlop
  //- benutzt wird, braucht man eine Negative Flanke !
  //lcd.lineWrap();
  //lcd.print(" #send_pulse pin : " + String(pin));
  //- Impuls senden -----------------
  //digitalWrite(pin, LOW);
  analogWrite(pin, A_LOW);
  
  delay(TRIGGER_DELAY);

  //digitalWrite(pin, HIGH);
  analogWrite(pin, A_HIGH_2);
}

any tip would be nice..

if it cant be soluted this way
i mention to use a port-expander like
Adafruit_PWMServoDriver PCA9685 PWM-Port-Expander,which i have aready in use
..guess, that switching LED,driving Servo with PWM
or something else is similar..

Use digitalWrite instead of analog.

as i wrote

Tried to use them with digitalWrite and analogWrite

does not work , no chance..

Imagine that the LEDs are relays.

Everything works.

The analog pins can be used as digital pins with numbers starting from 54....

meanwhile it runs with Adafruit_PWMServoDriver PCA9685 PWM-Port-Expander..

may be, there are differences depending on Ardi.mega-version ?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.