Working Hands Free Switch |JH5363

For the next step with our hands free switches we have been tasked with connecting them to our Feather HUZZAH micro controllers and getting them to function appropriately as a switch.

I had three options with my foot switch because it had two independent switches built into one interface. I could either do a switch in series which would mean one would need to bride both connections to get an LED to turn on, I could do a switch in parallel which would allow both switches to trigger the same LED but connecting both would do nothing extra, or I could just use them as two separate switches. I opted for the last option because it is easier for debugging and makes for a more fun demo.

Materials:

  • breadboard
  • LED x 2
  • wires
  • solder
  • Feather HUZZAH ESP8266
  • 220 ohm resistors x 2
  • 10k ohm resistors x 2
  • tinfoil
  • cardboard

Process:

Because I already had the switch built all I really needed to do was complete the circuit. One problem was the wires I originally had coming from the foot switch were too short to reach one breadboard. To fix this I soldered extensions onto the original wires for a longer reach. I then plugged one side of the wires into power and the two wires from the other side into pins 4 and 5. I also made sure to connect these pins to ground via 10K ohm resistors in order to prevent floating values. All that was left was connect two LEDs to two other pins and then to ground with a resistor.

The only real problem I was having was getting the wires to connect with the bottom of the shoe. I believe when the shoe was going down it would push down on the plastic male-connector component of the wire making it hard to get a good connection between the wires and the piece of foil on the bottom of the shoe. To fix this I just wrapped the ends of these wires with tinfoil making sure that there would be a good connection. It then worked well.

Code:

The code was relatively straight forward for this. I just checked to see if one of the switches was reading HIGH, and if it was I turned on the corresponding LED, if it wasn’t I turned it off.

int ledG = 13;
int ledR = 14;
int footFront = 4;
int footBack = 5;

void setup() {
// put your setup code here, to run once:
pinMode(ledG, OUTPUT);
pinMode(ledR, OUTPUT);
pinMode(footFront, OUTPUT);
pinMode(footBack, OUTPUT);
}

void loop() {
// put your main code here, to run repeatedly:
if(digitalRead(footFront) == HIGH){ digitalWrite(ledG, HIGH);
}else{ digitalWrite(ledG, LOW);}

if(digitalRead(footBack) == HIGH){ digitalWrite(ledR, HIGH);
}else{ digitalWrite(ledR, LOW);}
delay(100);
}

without tinfoil padding on wires
tinfoil padding on wires

Video Demo