05: Programmable Electronics
7/15/19 – Programmable Electronics and a Glove Prototype
Today, I worked on using a button to control a few LEDs in a simple circuit, and then made the circuit more complicated so in the end, it was a small prototype of the glove mechanism for my final project.
I first set up two LEDs, a green one and a red one, in a circuit, and had them be controlled by a button. Since it was required that we use a “for” loop, I programmed them so the red LED would get brighter in a for loop while the button was not pressed, and then the green LED would turn on for real when the button was pressed. However, one problem that I ran into initially was that the green LED would only turn on after the red LED finished running through a cycle of the for loop whenever the button was pressed, even though I wanted the green LED to turn on immediately. To fix this issue, as per Nathan’s suggestion, I used the “interrupt” function. The interrupt function is a function that can be applied to a digital pin. Whenever the state of the digital pin is changed in a certain manner (in my code, it’s activated when the state goes from low to high), the function will run, “interrupting” the rest of the code and executing code that runs when the digital pin state is changed. I used the Arduino documentation to help figure out the syntax. Here’s how I used it in my code: The interrupt function fixed my issue, and my button/LED circuit ran smoothly afterwards!
Since a button is basically two leads that are either connected (when pushed down) or not, and that gives a binary reading to the Arduino, I realized that I could make my own button of sorts to turn this basic circuit into a prototype of the glove part of my final project. First, I cut a few small strips from the adhesive copper sheets (which are usually used to make custom circuits in the vinyl cutter) and soldered on the necessary wires and resistors. Then, I used the adhesive to place them on a scrap of cardboard and plugged the wires into my circuit, replacing the button. I used an extra scrap of copper to act as the actual “pressing” part, so when I put the copper down on the two leads, the LED would turn on. It worked surprisingly well!
Next, I wanted to also drive a motor when the leads were connected since that is similar to what my final project will eventually be able to do. I hooked up a simple motor circuit with a transistor and modified the if (switchState == HIGH)
statement so it would digitalWrite the motor pin to be high.
Finally, I replicated the copper leads part of my circuit onto a latex glove. I used a Sharpie to mark the place where the tip of my finger would hit my palm when bent, and then attached the copper and wires there. I wired up the glove into the circuit like my leads from before. One problem I had, though, was that the latex glove was too flimsy and the copper kept on bending the glove when I didn’t want it to, so for later prototypes I will have to likely use a fabric glove of some sort. However, the prototype worked very well, and I was able to actually control the motor’s movement by bending my finger!
In the future, I want to make the control via bending more accurate, and maybe use sensors (either capacitors or magnetic sensors) to get a more specific reading from my hand movement and adjust the motor speed accordingly.