I wanted to explore having 2 inputs to 1 output in my Internet of Things (IoT) device design. I decided to use a flex sensor because of the interesting applications it could have in structural monitoring or testing. A button was used as my other input because it is common to have a switch or a button to turn devices on or off. I used 3 different color light emitting diodes (LEDs) to show low, medium, and high flex.
I started with wiring and testing each component. To test them to make sure my wiring was working I would make a simple code to turn them ON if it was an output and to display the value if it was an input. Once I had all my component working, I first made it so that my flex sensor would always map to the different LEDs and display without taking the button push into account. Once that worked, I added functionality around that to only display to the LEDs when the button was pushed. I had an issue where the range of inputs I got from my flex sensor was smaller than expected so I had to adjust my value map.
I used a Photon 2 microcontroller for this project. The Photon 2 allowed me to publish output values from my flex sensor to the Particle Console that was connected to the microcontroller over Wi-Fi. I used conditional statements to control which LED turned on which you can see in my code. I have also included a video of me testing it out where I start with the button pressed and you can see the flex output change, then I release the button, and the LEDs turn off until I press the button again.
I learned about live publishing values to the Particle Console in a way that does not require you to manually keep refreshing a variable. I also learned about using a flex sensor. In the future I would like to try and figure out how to get a larger value range from my flex sensor.
You can upload files of up to 20MB using this form.