Output Devices


This week we were tasked with an individual set of activities and group work. Working as a group, we needed to measure the power consumption of an output device. For our individual activities this week we were tasked with adding an output device to our microcontroller board and make it do something.

My group got right to work setting up multiple boards and codes we can test with. We used a multimeter to test a handful of components on our boards.

I had some familiarity for this week's activity, so I jump started our group with some research we can refer to when we are doing our testing. I created us a reference table with the typical power consumption of components we may use in this week or our final projects. I helped explain to members of my group how to use the multimeter in our circuits to get the measurements we need to calculate the power consumption values. And alongside Dorian, I explained the Power formulas we would need to use with our measurements. For a more in depth look at my groups week 9 assignment, see my groups Week 10 page.

Week 10

Check List

This week's project requirements:

    Group Assignment:

  • Measure the power consumption of an output device.
  • Document your work on the group work page
  • Reflect on what you learned on your individual page

    Individual Assignment:

  • Add an output device to a microcontroller board you’ve designed and program it to do something.
    • Document the process

    Images/Files:

  • Include your original design files
    • Properly compress or use a zip folder if needed
    • Include hero shots of your results

Resources and Helpful Links

Learning Outcomes

  • Demonstrate workflows used in controlling an output device(s) with MCU board you have designed.

Introduction


After solving the issue, from last week, with my board not working and realizing it was a power issue with the USB dongle I was plugging into, I felt like this week was going to go much smoother. Overall, it did. Having a week that runs smoothly is a great confidence boost after having so many little things go wrong in the previous two weeks. Adding my output was as simple as connecting the component and adding it to my code. Quick and EASY! Could I have challenged myself more this week? Probably, but I really needed a quick win after the last few weeks.

Adding an Input

Flex Sensor


I kept it simple this week by adding an output to my already created board from week 9. I decided to use a Flex Sensor by Spectra Symbol as my input component. At one point during my final project planning I debated trying to connect a flex sensor or possibly conductive rubber internally for my stringing system. My thought process was that I could turn pulling on things like the hands or feet into possible interactivities with the robot. I had played with the flex sensor a couple times by attaching it to a small cut off of my elastic but I really couldn't get it to flex enough for a readout. Stretching the elastic string in the doll body isn't really meant to happen often and it's meant to be in tension for stability, so in the end, I don't think the interactivity element would work for my final project.

But since I already had this component on hand and had been fiddling with it, I felt like it was a good input to start with that wasn't the usual button.

The sensor has two pins, the left one is used for power. The Right pin needs to be in an Analog Pin. This is important, because the sensor will look like its working in the serial monitor if you use a different pin. But in reality, the values are very high and no noticable change happens when bent.

The sensor also needs a 10K Ohm resistor split between the data pin and ground. The 10k ohm resistor is very important, because it acts as a voltage divider. While I had been fiddling with the sensor I initially tried using it without the resistor. My values were very high, in the 4000's and bending didn't make any noticable change over the noise in the sensor. When I tested with 1k and 2k ohm resistors my values dropped to the 1000's but had minimal to no change when bending. It wasn't until I put in the 10k ohm resistor did my values drop to the 300s and have significantly noticable changes when bent.

To ensure I had the sensor connected I used a basic example code to test it working. I found a very simple code for this sensor on this website. This page is also very helpful with learning more about this type of sensor and wiring the pins. I copy and pasted in the code and adjusted my pin locations and gave it a test run.

Test Code
Test Code Monitor


I was able to flex the sensor and see the readout change in the serial monitor. Now the next step is to add in my output and update the flex sensor code to turn on or off my output based off a flex amount.

Adding an Output

RGB LED Strip


My mantra for this week was keep it simple. My goal was to have the LED strip change colors when specific bend thresholds were met. When the sensor is flexed low the LED strip will glow red, and when the sensor is flexed high the LED strip will glow green. When the sensor is untouched the LED strip will glow blue.

Getting it all wired up on my breakout board was a little bit tricky since I had to get one leg of the 10k resistor and one lead of the sensor pin in the same header.

Close up of wiring on breakout board


I managed to pop the header off twice in the process, but nothing a little solder can't fix. And thankfully, I didn't burn any pads off in the process of fixing it over and over.

I pulled up my code from my week 9 flex sensor and single LED. I used this code as a basis for my RGB LED strip code.

Week 9 LED Flex code


Each color in the LED strip needed their own pin and code commands. One for red, one for green, and one for blue. I then made an if/else statement which stated to keep the lights blue when not flexed, red if the flex value is under 300, and green if the flex value is over 700.

Modified flex code from week 9


The code seemed good in theory and I was pretty confident it would work, but instead, my LED strip was showing all the wrong colors. Blue was always on causing some weird color effects. Green and red were not turning on as expected with the thresholds, they were actually turning on opposite what I expected.

My first thought was to check the wiring, then the code. The wiring was fine and the code matched the wiring. So I was a little confused why my colors were backwards and turning on/off at the wrong thresholds. I played with the code and realized that the on/off for this strip was backwards from the LED I blinked with the sensor in week 9.

I needed to swap the High and Low commands in my code. LOW is: ON
HIGH is: OFF

With the High and Low swapped, I had a working build!



Week 10 Files


In my repo is a zip folder containing files for my week 9.
What files are inside my Folder:
  • My final (working) Flex Sensor and LED Strip code Download My Week 10 Project Files Zip Folder