Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to make XOR or XNOR logic gate in Scratch?
- EvanD2008
-
100+ posts
How to make XOR or XNOR logic gate in Scratch?
I don't need help with any scripts, I was just curious on how you would make an XOR or XNOR logic gate. An XOR logic gate is an “Exclusive OR”. If two or more inputs are 0 or 1, the output is 0, but if only one of the numbers are 0 or 1, and the rest are the opposite, the output is always 1. An XNOR logic gate is an “Exclusive NOT OR”, which inverts the XOR logic gate. How would I replicate this in Scratch?
- jaofoody1
-
66 posts
How to make XOR or XNOR logic gate in Scratch?
Lol you gotta love logic gates. I’ll send you some code for it later ok? I’m on mobile rn I don't need help with any scripts, I was just curious on how you would make an XOR or XNOR logic gate. An XOR logic gate is an “Exclusive OR”. If two or more inputs are 0 or 1, the output is 0, but if only one of the numbers are 0 or 1, and the rest are the opposite, the output is always 1. An XNOR logic gate is an “Exclusive NOT OR”, which inverts the XOR logic gate. How would I replicate this in Scratch?
- jaofoody1
-
66 posts
How to make XOR or XNOR logic gate in Scratch?
XOR
if <<<(Input 1) = [1]> and <(Input 2) = [0]>> or <<(Input 1) = [0]> and <(Input 2) = [1]>>>then
set [Output v] to [1]
else
set [Output v] to [0]
end
Last edited by jaofoody1 (Feb. 27, 2021 16:10:34)
- EvanD2008
-
100+ posts
How to make XOR or XNOR logic gate in Scratch?
Lol you gotta love logic gates. I’ll send you some code for it later ok? I’m on mobile rn
Actually, I was doing IT homework and remembered about a similar language based on Scratch that had it, and since there is no such block in Scratch, perhaps there would be some way to do it.
- jaofoody1
-
66 posts
How to make XOR or XNOR logic gate in Scratch?
Ok I’ve done XOR for youLol you gotta love logic gates. I’ll send you some code for it later ok? I’m on mobile rn
Actually, I was doing IT homework and remembered about a similar language based on Scratch that had it, and since there is no such block in Scratch, perhaps there would be some way to do it.
- EvanD2008
-
100+ posts
How to make XOR or XNOR logic gate in Scratch?
Actually, I was doing IT homework and remembered about a similar language based on Scratch that had it, and since there is no such block in Scratch, perhaps there would be some way to do it.
Ok I’ve done XOR for you
Thanks! I'll check if it works. I was kind of already assuming that's how you do it, but at least people will get to see this forum and get their question answered.
Ok I’ve done XOR for you
Thanks! I'll check if it works. I was kind of already assuming that's how you do it, but at least people will get to see this forum and get their question answered.
- Oumuamua
-
1000+ posts
How to make XOR or XNOR logic gate in Scratch?
XOR not(a=b)
Last edited by Oumuamua (Feb. 27, 2021 20:55:48)
- deck26
-
1000+ posts
How to make XOR or XNOR logic gate in Scratch?
If you use 0 for false and 1 for true XOR just means the sum is 1. So the inverse if if the sum is not 1.
- jaofoody1
-
66 posts
How to make XOR or XNOR logic gate in Scratch?
You could just add them
But that seems less like a logic gate and more like addition - logic gates are sometimes used to do addition, so it’s sort of cheating if you used addition to do the logic gates, but it’s much quicker
if <((Input 1) + (Input 2)) = [1]> then
set [Output v] to [1]
else
set [Output v] to [0]
end
But that seems less like a logic gate and more like addition - logic gates are sometimes used to do addition, so it’s sort of cheating if you used addition to do the logic gates, but it’s much quicker
Last edited by jaofoody1 (Feb. 27, 2021 18:40:51)
- SlenTheOoof
-
93 posts
How to make XOR or XNOR logic gate in Scratch?
use
<<<<x> or <y>>> and <<not<<<x> and <y> >>>>>for xor and just add a not for xnor
- SlenTheOoof
-
93 posts
How to make XOR or XNOR logic gate in Scratch?
whoops about the red background
- Discussion Forums
- » Help with Scripts
-
» How to make XOR or XNOR logic gate in Scratch?