Programming with Controllino

I have to make a short code.

If my switch goes to high

1 Out has to go at the same time as my switch

2 Out needs a delay of 1 Sec

than when i turn my swich off

1 Out needs a delay of 0.5 Sec

2 Out has to go off at the same time as my switch

so i programmed this but it doesn’t show the right function: I used the controllino library

#include <SPI.h>
#include <Controllino.h>

int schalterstatus = 0;

void setup() {

DDRD = DDRD | B10000000; // Port D, pin 7 is configured as output - corresponds with Digital Output 3 of CONTROLLINO MINI
DDRD = DDRD | B01000000; // Port D, pin 6 is configured as output - corresponds with Digital Output 2 of CONTROLLINO MINI
DDRD = DDRD | B00100000; // Port D, pin 5 is configured as output - corresponds with Digital Output 1 of CONTROLLINO MINI

pinMode(CONTROLLINO_A0, INPUT);

}

void loop() {

schalterstatus=analogRead(CONTROLLINO_A0);
if (schalterstatus == HIGH)
{
PORTD = PORTD | B01000000; // sets Digital Outputs 0,1,2,3 in one shot to HIGH → turns the LEDs ON
delay(1000); // wait for 1 second
PORTD = PORTD | B00100000; // sets Digital Outputs 0,1,2,3 in one shot to LOW → turns the LEDs OFF
delay(1000);
}

else if ( schalterstatus == LOW)
{
PORTD = PORTD | B00100000; // sets Digital Outputs 0,1,2,3 in one shot to LOW → turns the LEDs OFF
delay(1000);
PORTD = PORTD | B01000000; // sets Digital Outputs 0,1,2,3 in one shot to HIGH → turns the LEDs ON
}
}

Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is that the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier to read your code and to copy it to the IDE or editor. If your browser doesn’t show the posting toolbar then you can just manually add the code tags:
[code]``[color=blue]// your code is here[/color]``[/code]
Using code tags and other important information is explained in the How to use this forum post. Please read it.

Please always do a Tools > Auto Format on your code before posting it. This will make it easier for you to spot bugs and make it easier for us to read. If you’re using the Arduino Web Editor you will not have access to this useful tool but it’s still unacceptable to post poorly formatted code. I recommend you to use the standard IDE instead.

ArduinoGUIDE:

 schalterstatus=analogRead(CONTROLLINO_A0);

if (schalterstatus == HIGH)

analogRead() returns a value between 0 and 1024. HIGH is equal to 1, LOW is equal to 0. HIGH and LOW are not relevant to use with analogRead().

For more information see:
https://www.arduino.cc/reference/en/language/functions/analog-io/analogread/
https://www.arduino.cc/reference/en/language/functions/digital-io/digitalread/