11 years, 2 months ago.

XOR Function

I feed a square wave signal to the mbed and I need to Xor the signal. is that possible?

I am new to the programming language and mbed world

thanks in advance

1 Answer

11 years, 2 months ago.

Hi Majed,

There are some examples of logical functions on the DigitalIn handbook page if they are useful:

Boolean logic - NOT, AND, OR, XOR

#include "mbed.h"
 
DigitalIn a(p5);
DigitalIn b(p6);
DigitalOut z_not(LED1);
DigitalOut z_and(LED2);
DigitalOut z_or(LED3);
DigitalOut z_xor(LED4);
 
int main() {
    while(1) {
        z_not = !a;
        z_and = a && b;
        z_or = a || b;
        z_xor = a ^ b;
    }
}

Simon

Accepted Answer