Week 9: Output Devices


Here is the group assignment link for this week!


This week we learned about output devices and how to apply them to the baords we are making ourselves.

I want to mantion some takeaways first, based on specific challenges that I've been encountering: my PCB board connectivity isn't always as reliable and I have had to troubleshoot quite a bit to address this issue.

It's been a good learning tool to run into this issue due to the considerations to keep in mind when designing and milling a board and then soldering components onto it. It's also time consuming to use a board that doesn't connect easily to a port/computer, but figuring out what works when a board isn't responding is a valuable spot to be in regardless.


Here are a couple of learnings as a note to self and hopefully others:


Using the same board I printed and worked with previously, the idea was to make use of the touch capacitance built into the board itself. Since I have been following Quentin Bolsee's lead.

My capacitive touch pads correspond to these pins:


At first, I needed to make the LED on PIN 31 blink in accordance to a specified reading threshold. The code, which includes the open source Adafruit Library, is as follows:


#include 

            // Create capacitive touch objects for pins 5, 14, and 15
            Adafruit_FreeTouch qt5(5, OVERSAMPLE_4, RESISTOR_50K, FREQ_MODE_NONE);
            Adafruit_FreeTouch qt14(14, OVERSAMPLE_4, RESISTOR_50K, FREQ_MODE_NONE);
            Adafruit_FreeTouch qt15(15, OVERSAMPLE_4, RESISTOR_50K, FREQ_MODE_NONE);

            const int ledPin = 31; // Pin for the LED

            void setup() {
            // Initialize the capacitive touch sensors
            qt5.begin();
            qt14.begin();
            qt15.begin();

            pinMode(ledPin, OUTPUT); // Set the LED pin as an output
            }

            void loop() {
            // Read the capacitive touch values for each pin
            int qt_value5 = qt5.measure();
            int qt_value14 = qt14.measure();
            int qt_value15 = qt15.measure();

            // Check if any touch value exceeds a threshold (adjust as needed)
            if (qt_value5 > 550 || qt_value14 > 550 || qt_value15 > 550) {
            // If touched, turn on the LED
            digitalWrite(ledPin, HIGH);
            } else {
            // If not touched, turn off the LED
            digitalWrite(ledPin, LOW);
            }
            }


In this modified code:

Running this code was unsuccessful for me. I tried different things, but as I am not well versed in programming and working with the Arduino IDE yet, I couldn't figure out what the source of the issue was.

Following Andrea Rubio's documentation after not getting any touch capacitance results, I attempted to download the 1.1.2 version of the Adafruit Library to see if it gave me any results. I did this because apparently, there's an issue with trying to run this code on the latest version.


LINK TO 1.1.2 VERSION


While adding the library as a .zip file seemed to work smoothly, and after multiple restarts to the Arduino IDE program after doing so, the 1.1.2 version was not showing up as an option. The versions available jumped from 1.1.1 to 1.1.3.

As much as I tried to implement the 1.1.2 version, which seemed to work for my peeer, I was unsuccessful. I had to use another method to get the touch capacitance to work, so I defaulted on this code, thanks toChristine Grupel's solution, which is documented on her page.


              #define PIN 5
              #define PIN2 14
              #define PIN3 15
              #define LED 31
              
              void setup () {
              
                Serial.begin(115200);
                pinMode(PIN, INPUT_PULLUP);
                pinMode(PIN2, INPUT_PULLUP);
                pinMode(PIN3, INPUT_PULLUP);
              
                pinMode(LED, OUTPUT);
              
              }
              
              void loop(){
                Serial.print ("PIN=");
                Serial.print(analogRead(PIN));
                Serial.print ("PIN2=");
                Serial.print(analogRead(PIN2));
                Serial.print ("PIN3=");
                Serial.println(analogRead(PIN3));
              
                if (analogRead(PIN) >= 800 || analogRead(PIN2) >= 500 || analogRead(PIN3) >= 800) {
                  digitalWrite(LED, HIGH);
                }
                else {
                  digitalWrite(LED, LOW);
                }
                delay(200);
              
              }
            
            


This offered some results, however, PIN 14 proved unresponsive while the program was running, so it gives me something to troubleshoot and figure out in the coming days. I had determined earlier on that the power provided by the USB port is enough, based on any troubleshooting I did with advisors and my instructors, but that is also an important factor to keep in mind. I'm not saying that it affects my non-working pad, but just as a general detail to keep in mind...