30
LuxARTS
6y

input = readPin(x);
if (input == 1)writePin(y, 1);
if (input == 0)writePin(y, 0);

(When I saw this I wanted to pull off my eyes)

Comments
  • 0
    What ifthe input may be 2 or 3 or 4...etc
    Then you want for 0 and 1 only
  • 2
    @XPoint then you do bounds checking...

    if(input < 2)
  • 4
    @XPoint readPin() will never return 2 or 3. It's a function that read a logical state of pin (in this case 1=3.3v and 0=0v). Same with writePin().
    Also, the best solution for all cases is:
    writePin(y, readPin(x));
Add Comment