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
}
}