For my Arduino One I have implemented a pulsating output with the use of pwm.
I want to combine that output with another output into a final output so that the final output is the result of a logical or-gate.- Is it possible to do that software wise or do I need some external components?
You can implement a logic OR in code. Something like below pseude code
if(someCondition == true)
{
digitalWrite(pinPWM, HIGH);
// or
analogWrite(pinPWM, 255);
}
else
{
analogWrite(pinPWM, someValue);
}
Here is the result of ?? || ??:
void setup() {
Serial.begin(115200);
}
void loop() {
Serial.print(1);
}
sketch.ino
int i, j;
void setup() {
Serial.begin(115200);
}
void loop() {
int i = random(256);
int j = random(256);
Serial.print(i, BIN);
Serial.print(" ");
Serial.print(j, BIN);
Serial.print(" i || j = ");
Serial.print(i || j, BIN);
Serial.println();
delay(250);
}
I would say an or gate would be preferable. A serviceable gate can be made with two diodes and a resistor, maybe that's all depending on what the output of the needs to drive.
Software? Maybe. A straightforward approach woukd be to connect the PWM output to an input and use the value you read at that pin together with whatever your other output value is.
But you'll have to do that fairly often, as the PWM signal is cranking away.
bool pwmIsHigh = digitalRead(connectedToPWMOutputPin);
// get whatever the other output is into otherOutput
if (otherOutput || pwmIsHigh)
digitalWrite(orOutputPin, HIGH);
else
digitalWrite(orOutputPin, LOW);
If you use one of the low frequency PWM pins, you'll still have to execute that logic frequently and regularly.
Try it, I did not.
a7
But srsly we should be asking you why you want to do that, to what end.
It is very probable that you are solving the wrong problem ,or not thinking about it if this is what you come up with as a solution.
So… what are you up to over there?
a7
I used the time waiting for she who will not be kept waiting to test the software idea.
Trust but verify: it is unsatisfactory even when the calculation is done as rapidly as possible with straight-ahead code.
a7
- When you use this too many times, she will find out, your life could become complicated

In fact I need a pulsating signal (square) for an amount of time and after that amount of time I need a constant HIGH signal.
Then just use tone() and notone() and set the digital pin HIGH after noTone().
https://docs.arduino.cc/language-reference/en/functions/advanced-io/tone/
Eew, clever! I love it!
-jim lee
what is the exact pattern timewise?
Wire the outputs in parallel and you have one output that is ON when either of the two wired outputs is ON.
You can wire switches in series to make an AND gate and switches in parallel to make an OR gate and switches in a crossed way to make an XOR gate. When the power switches itself, the parallel OR gate still works but the final output will vary as to V and A.
Do we know that the required duty cycle is 50%.
EDIT
Oops. He said said square wave.