HTMAA 2024 - Week 8

Previous: Molding and Casting Home Next: Output Devices

Week 8: Input Devices

For this part of the project, a simple switch was sufficient to meet the requirements. The switch is used to detect whether the boogie board is in use or available. It also serves as a diagnostic tool to alert me if something malfunctions.

Switch Setup
The Switch

After following the instructions provided by Seeed Studio on programming the microcontroller using the Arduino interface, I implemented the following code to operate the switch:

// Define the pin to which the switch is connected
const int switchPin = D1;

void setup() {
  // Start the Serial Monitor (set your desired baud rate)
  Serial.begin(115200);

  // Configure the switch pin as an input with the internal pull-up resistor
  pinMode(switchPin, INPUT_PULLUP);
}

void loop() {
  // Read the state of the switch:
  //  - LOW means the switch is pressed (ON)
  //  - HIGH means the switch is not pressed (OFF)
  int switchState = digitalRead(switchPin);

  if (switchState == LOW) {
    Serial.println("Switch is ON");
  } else {
    Serial.println("Switch is OFF");
  }

  // Add a small delay to avoid flooding the Serial Monitor
  delay(500);
}
        
Switch Code
The Switch Code

The terminal output successfully displays the switching states, confirming that the switch is functioning as intended.

Group Assignment

For the group assignment, we gathered in the CBA lab, where Erik demonstrated the use of various tools to analyze digital and analog signals. We used the Saleae logic analyzer, a magnetometer, and an oscilloscope to observe and interpret different types of signals.

Switch Code
Photo credit to Michelle

Assignments