0
\$\begingroup\$

I was trying to make a circuit using 7 segment and arduino logic state and I am successful in showing binary number on 7 segemnt as take input from logic state but now when I am trying to code for gray code like I wanna show 2 binary into Gray that is 3 not working any idea As I use arduino pin 12,11,10 for input for binary representation but pin 4,5,7 for gray representation but I'm stuck in gray I'm using xor gate but it's not working

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$
grey2bin(unsigned n){
  unsigned m=n;
  while(n>>=1) m^=n;
  return m;
}
\$\endgroup\$
2
  • \$\begingroup\$ No actually on arduino I'm using pin 12 11 10 3 pin of arduino for input and it is connected with ic and then 7 segemnt this one showing binary and pin 4 5 7 for gray code it is connected with ic and 7 segment but when I code for gray at pin 4,5,7 I wrote pin mode input and a ^b^c but it's not working hope u get my point \$\endgroup\$ Jan 5, 2021 at 11:37
  • \$\begingroup\$ you should combine those pins to make a binary number, convert from gray and then do whatever you need with the binary. \$\endgroup\$ Jan 5, 2021 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.