Hello
Does anybody have an idea, why the two signals are starting at different points of time?
I want them to start at the same time, but stay on for seperate times.
I attached a screenshot from my oscilloscope.
It looks like the case of setting the pin low is synchron but I want them to start high synchronous.
Thanks for your answers.
Crameroni
int VVRPin = 22; // the number of the VVR pin
int VDRPin = 23; // the number of the VDR PINint VVRState = LOW; // VVRState used to set the VVR
int VDRState = LOW; // VDRState used to set the VDRunsigned long previousVVRMillis = 0; // will store last time VVR was updated
unsigned long previousVDRMillis = 0; // will store last time VDR was updatedlong VVROnTime = 25; // milliseconds of on-time VVR
long VVROffTime = 1970; // milliseconds of off-time VVR
long VDROnTime = 210; // milliseconds of on-time VDR
long VDROffTime = 1785; // milliseconds of off-time VDRvoid setup()
{
// set the digital pin as output:
pinMode(VVRPin, OUTPUT);
pinMode(VDRPin, OUTPUT);
}void loop()
{
unsigned long currentMillis = millis();if ((VVRState == HIGH) && (currentMillis - previousVVRMillis >= VVROnTime))
{
VVRState = LOW; // Turn it off
previousVVRMillis = currentMillis; // Remember the time
digitalWrite(VVRPin, VVRState); // Update the actual VVR
}
else if ((VVRState == LOW) && (currentMillis - previousVVRMillis >= VVROffTime))
{
VVRState = HIGH; // turn it on
previousVVRMillis = currentMillis; // Remember the time
digitalWrite(VVRPin, VVRState); // Update the actual VVR
}if ((VDRState == HIGH) && (currentMillis - previousVDRMillis >= VDROnTime))
{
VDRState = LOW; // Turn it off
previousVDRMillis = currentMillis; // Remember the time
digitalWrite(VDRPin, VDRState); // Update the actual VVR
}
else if ((VDRState == LOW) && (currentMillis - previousVDRMillis >= VDROffTime))
{
VDRState = HIGH; // turn it on
previousVDRMillis = currentMillis; // Remember the time
digitalWrite(VDRPin, VDRState); // Update the actual VVR
}
}