Week 9 – Analog and Digital Sensors

Description:

I really wanted to try using the ultrasonic motion sensor for this week’s assignment and control both audio and visuals with it. Being able to have your hand control something without touching it seemed cool to me, kind of like the theremin instrument that allows musicians to wave their hand in the air to produce different notes. My assignment is much simpler, but has a similar idea in that the closer your hand gets to the sensor, the lower the pitch. I also have LEDs hooked up that get dimmer the closer your hand gets and brighter the farther away. For the digital sensor, I have a button controlling my 4 LEDs; the button allows you to toggle between the LEDs individually. Once you’ve gone through all the LEDs and press the button again, all of them turn on. 

Video demonstration:

Schematic:

Difficulties:

I had a hard time with the button because it wasn’t as simple as pressing it to toggle between the LEDs. When you press the button, you’re technically holding it and giving it HIGH voltage for multiple frames. That means within one button press, I’m toggling between who knows how many LEDs. However, I only want one button press to change one thing. I did some scouring online and found this state-changing example that made me realize I can just detect when the button goes from LOW to HIGH (off to on). By keeping track of the last button state and current button state, I can detect when the user clicks the button. That instance determines whether or not to toggle between the LEDs: https://docs.arduino.cc/built-in-examples/digital/StateChangeDetection/

Button state change:

// compare current and previous button states, see if there's change
if (buttonState != lastButtonState) {
   // if HIGH, button went from off to on
   if (buttonState == HIGH) {

Mapping distance to LED brightness:

analogWrite(LEDarr[currentLED], map(dist, 0, 20, 0, 255));
if (dist < 3) {
  analogWrite(LEDarr[currentLED], 0);
}

It was also difficult making the different pitches noticeable since the motion sensing isn’t the most accurate and there’s not a huge range to work with. To counteract this, I chose notes that were very far apart from each other to make the change in sound due to distance more apparent. I also made sure to print out the distances to how far a person would comfortably go away from the sensor and used that as my max.

Looking forward:

In the future, it would be nice if maybe I map a specific LED/color to a specific note or melody so that when I play songs from the speaker, the lights match accordingly. It would also be cool if I can play a song from the motion sensor and choose what notes to play given the distance/motion.

Assignment 9: Analogue and Digital

For this week’s assignment, we were tasked with controlling two LEDs using analogue and digital means. For my project, I decided to utilize the photoresistor to control one of the LEDs.

The idea was to have one LED controlled by a button, while the second LED would change its brightness depending on how much light the photoresistor detected. This works through the photoresistor sitting next to the first LED, so when it turns on, the second LED gets dimmer, and vice versa.

The components I used were:

  • Arduino Uno
  • Breadboard
  • Wires
  • 2 LEDs
  • 2 330 ohms resistors
  • 1 button switch
  • 2 10k ohm resistors
  • 1 photoresistor

Video of the circuit:  https://drive.google.com/file/d/18Y1VjX12o3Z_u9x9rxtTDF2E-SOxcpOG/view?usp=sharing

Schematic:

The code:

const int buttonPin = 2;    // Button input pin
const int led1Pin = 8;      // LED1 (button-controlled)
const int photoPin = A0;    // Analog input for photoresistor
const int led2Pin = 9;      // LED2 (brightness controlled by light)

void setup() {
  pinMode(buttonPin, INPUT);      // Set button pin as input
  pinMode(led1Pin, OUTPUT);       // Set LED1 pin as output
  pinMode(led2Pin, OUTPUT);       // Set LED2 pin as output
  Serial.begin(9600);             // Start Serial Monitor for debugging
}

void loop() {
  int buttonState = digitalRead(buttonPin);   // Check if button is pressed

  // Control LED1 based on button
  if (buttonState == HIGH) {
    digitalWrite(led1Pin, HIGH);  // Turn on LED1 if button is pressed
  } else {
    digitalWrite(led1Pin, LOW);   // Otherwise, turn it off
  }

  // Read the light level from the photoresistor
  int lightLevel = analogRead(photoPin);  // 0 (dark) to 1023 (bright)
  Serial.println(lightLevel);            
  // Convert light level into LED2 brightness (invert it!)
  int brightness = map(lightLevel, 0, 1023, 255, 0);
  brightness = constrain(brightness, 0, 255); // Make sure value stays in range

  analogWrite(led2Pin, brightness); // Set brightness of LED2

  delay(10);  // Small delay
}

The coding was probably the hardest part, as I was struggling with having the photoresistor convert the binary values into a values that would be suitable for the resisitor, and would show a noticeable decrease in brightness in the second LED.

Overall, this was an interesting project, and I was able to better understand some functions within the Arduino IDE program and the way a photoresistor could be utilized.

 

Week 9 — Reading Response

Reading Tom Igoe’s articles helped me understand physical computing in a more thoughtful way, beyond just wiring things up and making LEDs blink (which to be fair, I do think is a preconceived notion that I have been gradually worn down through consecutive projects and readings in the class). In the first article (“Physical Computing’s Greatest hits and misses”), I appreciated how he explained that physical computing is really about building systems that can sense and respond to the world around them. This also reminded me of the discussion we had a couple of weeks ago on what defines interactivity. It also stood out to me because it made me think differently about my lie detector project — that I wasn’t just turning on lights but also creating a playful, real-world interaction in response to physical stimuli.

The second article (“Making Interactive Art: Set the Stage, Then Shut Up and Listen”) focused more on the nature of interaction, and it really resonated with me. He explains that real interaction happens when the user has control over the timing and nature of the input, rather than just pressing a button and triggering a fixed response. That reminded me of how, at first, my green LED would turn on as long as the button was pressed, even if there wasn’t enough pressure. It didn’t feel right, and reading this made me realize why. The system was reacting too easily, without enough real input from the user (this is also my re-interpretation of the event as well since this connection was mentally made a bit later). Adding a lower threshold fixed that and made the interaction more accurate. I think, overall, I’m left with concepts and ideas that can serve as tools to frame my projects and skills in this class, especially in the aspect of understanding interactivity and intentionality.

Week 9 – Serial/Analog Input – Smile and Wink!

CONCEPT:

For this week’s assignment, I made a smiley face with two glowing eyes, where they “wink” in between. One of the LEDs brightness was controlled using a photoresistor, and the other turned on/off using a switch.

MATERIALS USED:

Arduino UNO

Breadboard

Photoresistor

10K Ohm resistor

330 Ohm resistor

Switch

LED

Jumper wires

WORKING:

So one of the LEDs are controlled using the photoresistor. It gets brighter when the photoresistor is covered(less light), and vice versa. The other LED is controlled using the switch. The code for it is as follows:

const int button = 2;
const int led1 = 13;
const int led2 = 9;
const int ldr = A0;

int state = LOW; //state of LED1
int brightness = 0; //brightness of LED2
int ldrValue = 0; //photoresistor value

void setup() {
  pinMode(button, INPUT_PULLUP); 
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  
  //serial monitor for debugging
  Serial.begin(9600);
}

void loop() {
  if (digitalRead(button) == LOW) {
    state = HIGH;  //turn LED1 on
  } else {
    state = LOW;   //turn LED1 off
  }
  
  //read photoresistor value and map it to LED2 brightness (0 to 120)
  ldrValue = analogRead(ldr);
  brightness = map(ldrValue, 0, 1023, 0, 120);
  
  Serial.print("LDR Value: ");
  Serial.println(ldrValue);
  
  //control LED1 using switch (physical input)
  digitalWrite(led1, state);
  
  //control LED2 brightness using analog input
  analogWrite(led2, brightness);

  delay(100);  //small delay for stability
}

CHALLENGES :

The challenging part about this was my biggest careless mistake! I put the LED on oppositely (anode and cathode), so I spent a good 30 minutes trying to figure out what went wrong. I also used the serial monitor to help with debugging.

Hand drawn schematic:

LINK TO VIDEO :

https://youtube.com/shorts/UVZ-qTWX1aE?feature=share

IMPROVEMENTS :

I would like the photoresistor-controlled LED to be better, maybe some other form of coding that makes it more…interesting. I also realised that we wink using our eyelids and not the eyes themselves, but overall, as a form of cartoonish smiley-ness, I’m happy with this project. It was a fresh start after the spring break!

Physical Computing’s Greatest Hits (and misses)

The text explores recurring themes in physical computing projects and makes a strong case for embracing these ideas, even if they’ve been done before. I really appreciated the encouragement to view these themes as starting points for originality rather than dismissing them as unoriginal. It’s easy to feel discouraged when you think your idea isn’t new, but this perspective reframes those recurring concepts as opportunities to innovate and personalize. For example, the section on theremin-like instruments stood out to me. While the basic idea of waving your hand over a sensor to create music might seem simple, the challenge lies in adding meaningful gestures or context to make it more expressive and unique. That idea of taking something familiar and pushing it further really resonates with me.

One theme that caught my attention was the “gloves” section, particularly the drum glove. I love how it builds on a natural human behaviour- tapping rhythms with your fingers- and turns it into something interactive and fun. The text points out that gloves already come with a gestural language we understand, which makes them accessible while still offering room for creativity. I started imagining how I could expand on this concept, maybe by incorporating haptic feedback or connecting the gloves to other devices for collaborative performances. It’s exciting to think about how these simple ideas can evolve into something much bigger.

That said, not all the themes felt equally engaging to me. For instance, while “video mirrors” are visually appealing, the text acknowledges that they lack structured interaction and often devolve into simple hand-waving. I agree with this critique- while they’re beautiful, they don’t feel as immersive or meaningful compared to something like “body-as-cursor” projects, which involve more dynamic movement and interaction. It made me think about how important it is to balance aesthetics with functionality in interactive design.

Overall, this text inspired me to see recurring project ideas not as limitations but as creative challenges. It also got me thinking about how physical computing bridges the gap between art and technology in such playful and human ways. Moving forward, I want to approach my own projects with this mindset- taking familiar concepts and finding ways to make them personal, meaningful, and interactive. There’s so much potential in these themes, and I’m excited to explore where they could lead.

Making Interactive Art: Set the Stage, Then Shut Up and Listen

This text really made me rethink the way I approach art and creativity. I love how it frames interactive art as a conversation between the artist and the audience, rather than a one-sided statement. The idea that the audience completes the work through their actions is so refreshing- it feels collaborative and alive. It reminds me of immersive installations like Yayoi Kusama’s “Infinity Rooms,” where the experience is deeply personal and shaped by how each person interacts with the space. I’m drawn to this idea of stepping back as an artist and letting others bring their own perspectives to the work.

At the same time, I struggle with the idea of completely “getting out of their way.” While I understand the importance of leaving room for interpretation, I think too little guidance can leave people feeling lost or disconnected. The text mentions giving hints or context, but it doesn’t really explain how much is enough. For example, if an interactive piece doesn’t make it clear what’s meant to be touched or explored, people might misinterpret it or feel unsure about how to engage. I think there needs to be a balance- enough structure to guide people without taking away their freedom to explore.

This text really got me reflecting on my own creative process. It made me think about how interactive art mirrors other forms of storytelling, like theater or video games, where the audience or players shape the experience. I love the idea of creating something that invites others to bring their own interpretations, but I also want to make sure they feel welcomed into that process. It’s definitely something I’ll keep in mind as I work on my own projects- how to create that balance between structure and freedom so that my work feels open but still accessible.

Week 9: Analog input & output

Concept:

This project is a reaction timer game built using an Arduino, a push button, a potentiometer, and two LEDs. The main idea is to test how fast a person can react after seeing a visual signal. One LED acts as the “start signal” light — when it turns on, the player must press the button as quickly as possible. The potentiometer controls how difficult the game is by adjusting the random delay time before the signal LED lights up. After the player presses the button, the Arduino measures their reaction time and shows it on the computer screen through the Serial Monitor.

The second LED is used to make the project more interactive by representing the player’s reaction speed through brightness. If the player reacts quickly, the second LED lights up brightly. If the reaction is slower, the second LED is dimmer. This gives instant visual feedback without needing to check the Serial Monitor every time. The whole project is a fun way to learn about digital inputs, analog inputs, and timing functions with Arduino, and it can easily be expanded with sounds, scores, or even multiple players later on.

int pushButton = 2;  // Button pin
int potPin = A0;     // Potentiometer pin
int ledPin = 8;      // LED pin

void setup() {
  Serial.begin(9600);
  pinMode(pushButton, INPUT_PULLUP);
  pinMode(ledPin, OUTPUT);
}

void loop() {
  int difficulty = analogRead(potPin);  // Read difficulty setting
  int waitTime = map(difficulty, 0, 1023, 1000, 5000); // Map to 1-5 seconds
  
  Serial.println("Get Ready...");
  delay(random(waitTime));  // Wait random time based on potentiometer
  
  digitalWrite(ledPin, HIGH);  // Turn LED ON (reaction signal)

  unsigned long startTime = millis();  // Start counting time
  while (digitalRead(pushButton) == HIGH) {
    // Wait for button press
  }
  unsigned long reactionTime = millis() - startTime;  // Reaction time calculation
  
  digitalWrite(ledPin, LOW);  // Turn LED OFF after button pressed
  
  Serial.print("Reaction Time (ms): ");
  Serial.println(reactionTime);
  
  delay(3000);  // Wait 3 seconds before starting again
}

Challenges:

My Arduino Board got stuck in an infinite loop through a test code I ran previously and stopped accepting any further code uploads. Due to this, I had to change my project idea and use a friend’s Arduino to run the code.

New Concept:

This is a simple circuit using 2 LEDs, a potentiometer, and a switch button. The potentiometer controls the brightness of the LED while the other LED is controlled by the button.

Week 9 — Sensors

Ideation

When I first started thinking about what to do for this project, I wanted to create something that was a bit playful (a bit gamified?), while also showcasing how analog and digital inputs can work together in a meaningful way. I landed on the idea of a “Human Lie Detector” — a lighthearted concept that mimics stress or honesty detection based on physical responses. This was inspired by an existing device that I often saw being used in Korean drinking games. For that machine, small electric shocks are sent the person who is attached to the machine based on the sweat produced by someone’s hand. Since I don’t intend to cause pain to any body I decided to use a sensor that could imitate the just of the lie detector idea. So, the pressure sensor became the core of the project, as it allowed me to measure subtle changes in finger pressure, which I imagined could simulate a person’s nervousness or calmness when answering a question. By combining this analog input with a digital button (to simulate the moment a person gives an answer), I could create a clear trigger point and decision logic for controlling the LEDs. The red and green LEDs became symbolic indicators: red for “lie” and green for “truth,” depending on how much pressure was applied.

Implementation

To bring the idea to life, I started by wiring up the core components: a pressure sensor, a pushbutton, and two LEDs (one red and one green). I used a 10k resistor to build a voltage divider circuit with the pressure sensor, allowing me to read its analog values through pin A0 on the Arduino. The pushbutton was connected to digital pin 2 and configured with Arduino’s internal pull-up resistor to simplify the circuit. For output, I connected the red LED to pin 8 and the green LED to pin 9. You can see the demo video below (sound ON):
IMG_0052

Here’s the schema I drew :

Code Highlights

One small but important part of my code was adding a mid-range threshold to control the green LED. At first, I noticed that the green LED would turn on even when there was barely any pressure on the sensor, just because the button was pressed. To fix this, I added a lower bound to the pressure range. So now, the green LED only turns on if the pressure is somewhere between a low (50) and high threshold (500). This simple change made the interaction feel a lot more accurate and intentional. It wasn’t a complex fix, but it solved an annoying issue and made the project work the way I wanted.

int threshold = 500;         
int lower = 50;
.
.
.
if (buttonState == LOW) {
  if (pressureVal > threshold) {
    digitalWrite(redLED, HIGH);
    digitalWrite(greenLED, LOW);
  } else if (pressureVal > lower) {
    digitalWrite(redLED, LOW);
    digitalWrite(greenLED, HIGH);
  } else {
    digitalWrite(redLED, LOW);
    digitalWrite(greenLED, LOW);
  }
} else {
  digitalWrite(redLED, LOW);
  digitalWrite(greenLED, LOW);
}

initially wrong code:

if (buttonState == LOW && pressureVal > threshold) {
  digitalWrite(redLED, HIGH);
  digitalWrite(greenLED, LOW);
}
else if (buttonState == LOW && pressureVal < lower) {
  digitalWrite(greenLED, HIGH);   // always turned on green LED if button is pressed
  digitalWrite(redLED, LOW);
}
else {
  digitalWrite(redLED, LOW);
  digitalWrite(greenLED, LOW);
}

Reflection

Interestingly, the most challenging part of this assignment wasn’t the coding or wiring; it was actually drawing the schematic. I found it surprisingly difficult to sketch the circuit accurately without having the physical components in front of me. To overcome this, I brought the components to my workspace from the IM lab and started building the circuit first, using the multiple schematics we learned about in class as references. I looked closely at the examples for the LEDs, the button, and the pressure sensor, and then worked backwards from my working setup to draw the schema. While this might not have been the intended approach for the assignment, it turned out to be incredibly educational for me. I ended up researching circuit diagram symbols and layout conventions on my own, which gave me a much better understanding of how to read and create schematics. In a way, doing it “backwards” helped me build my confidence on circuit drawings. So next time, (hopefully) I’ll feel ready to start with the schematic before jumping into the circuit.

Week 9: analog input & output

For this project, we were asked to use both a digital and an analog sensor to control two separate light bulbs. I chose an LDR as the analog sensor and a push button switchas the digital one.

The circuit was designed with both connections set up in parallel, but each individual sensor and its LED were wired in series. That means the LDR is connected to a resistor and then to an LED in one path, while the button switch is connected to a resistor and another LED in a separate path. Both paths share power and ground—so they’re technically in parallel, but operate independently.

My favorite part of the project was seeing how the LDR affected the brightness of the LED in real-time. The more light it receives, the dimmer the LED gets, and vice versa. It was satisfying to see that dynamic shift as I covered and uncovered the sensor.

 

For the digital sensor, the behavior is much simpler: the LED turns on when the button is pressed and turns off when it’s released. There’s no change in brightness—just a clean on/off action.

One challenge I faced was protecting the LEDs from burning out. I ended up frying three of them before realizing that I needed to be more careful with resistor values and connections. In the end I started disconnecting my board from power before making any changes to the connections which I realize now I should’ve done from the start but I just forgot about it.

For future improvements, I’d love to swap the LDR for a microphone sensor and make the LED respondto sound intensity instead of light. I thinkit would be fun to experiment with how volume or rhythm could control brightness, especially for interactive or musical projects.

Hand-drawn schematic diagram:

Switch not pushed. LDR exposed to room light.

Switch not pushed. LDR covered.

Switch pushed. LDR exposed to room light.

Week 8: Creative switch

For this project, I got inspired by bowling, and so I wanted to use a  rolling ball to control the LED light. The idea was to turn it into a competition between two players, where the goal is to light up a bulb three times before the other player.

To build this, I created a mini bowling alley out of cardboard. At the center of the alley, there’s a handle wrapped in copper tape. The game starts with the handle tilted at an angle, and each player takes turns rolling a ball, trying to push the handle into the exact center position. When the handle aligns just right, it connects with another piece of copper tape, completing the circuit and lighting up an LED. The first player to do this successfully three times wins the game.

My favorite part of this project was designing the handle mechanism and experimenting with the balance between accuracy and force.

One challenge I faced was adjusting the friction of the handle. At first, it slid way too easily, which made the game too simple and boring. But when I added more resistance, it became too difficult, and no one could win. After asking multiple people to try the game and integrating their feedback I finally reached a state where the game worked as I pictured it at the start and became enjoyable to play.

Things I’d like to improve in the future include adding a digital scoreboard to track each player’s progress and wins. I’d also like to experiment with different materials as cardboard was really hard to work with due to differences in friction between different kinds and cuts of cardboard.

Starting/Losing:

Winning: