Week 10: Dual Hybrid Sensor Lighting System

Concept: For this project, I need to use both digital and analog sensors along with indicators like LEDs to get creative. After thinking about different ideas, I realized my inspiration is:  I’ve always wanted to upgrade my Marvel’s Moon Knight action figure. Just like in the comics, I want his face and symbol on his chest to light up red when it’s dark, giving a warning to criminals. I also want some background lighting, like thunder effects. So, I thought of using some cool LEDs and sensors to recreate this scene. To achieve this, I’ll be using a photocell as the analog sensor and a push button as the digital sensor.

Materials I used:
1. Arduino Uno Board
2. Breadboard
3. Two Leds (Red and Green)
4. Three 220 Ohm Resistors
5. Push Button
6. Photo-resistor (Light Sensor)
7. Jumper Wires

So the final circuit include all of these items, as well as my Moon Knight Action Figure.

Implemented Code with comments:

int led = 11; // LED pin connected to an analog sensor
int buttonPin = 2; // Button pin, using pin 2 for example
int buttonState = 0; // Variable for reading the push button status
int secondLed = 12; // Second LED pin, using pin 12 for example
bool blinking = false; // State to control the blinking

void setup() {
  Serial.begin(9600); // Starts the serial communication
  pinMode(led, OUTPUT); // Sets the led as an output
  pinMode(buttonPin, INPUT_PULLUP); // Initialize the push button pin as an input with an internal pull-up resistor
  pinMode(secondLed, OUTPUT); // Sets the second led as an output
}

void loop() {
  int sensorValue = analogRead(A2); // Read the value from the analog sensor
  Serial.println(sensorValue); // Print the value to the serial monitor
  analogWrite(led, map(sensorValue, 0, 1023, 255, 0)); // Write the inverted analog value to the LED
  
  int currentButtonState = digitalRead(buttonPin); // Read the current state of the push button

  // Check if button state has changed from high to low (button press)
  if (currentButtonState != buttonState && currentButtonState == LOW) {
    blinking = !blinking; // Toggle blinking state
  }
  buttonState = currentButtonState; // Update the buttonState
  
  // If the button was pressed, start blinking
  if (blinking) {
    digitalWrite(secondLed, HIGH); // Turn on second LED
    delay(250); // Wait for 250ms
    digitalWrite(secondLed, LOW); // Turn off second LED
    delay(250); // Wait for 250ms
  } else {
    // Turn off second LED when sensor value reaches 200 or more
    if (sensorValue >= 200) {
      digitalWrite(led, LOW); // Turn off LED
    } else {
      digitalWrite(led, HIGH); // Turn on LED
    }
  }
  
}

Video Demonstation:

Images:

Figure 1.1: Closer View of the Circuit during Night time

Figure 1.2: Complete View of the Circuit, Including with Action Figure. (Night Time)

Figure 1.3: Top Angle View of the circuit during the Day time.

Sketch: Circuit Schematics

How circuit works:

LEDs and Resistors: There are two LEDs, a green and a red one. Each LED is connected to a digital pin on the Arduino (green to pin 11 and red to pin 12) through a resistor. The resistors limit the current to the LEDs to prevent them from burning out due to excessive current. The longer leg (anode) of the LEDs is connected to the resistor, and the other side of the resistor is connected to the Arduino pins. The shorter leg (cathode) of the LEDs is connected to the ground (GND) on the Arduino to complete the circuit.

PushButton:
The pushbutton has one side connected to 5V and the other side to both the ground (through a resistor) and to digital pin 2 of the Arduino. The resistor is a pull-down resistor that ensures the pin is at a known low signal when the button is not pressed. When the button is pressed, it connects the pin directly to 5V, giving a high signal. The internal pull-up resistor on the Arduino pin is activated in the code (INPUT_PULLUP), which means the pin is normally high, and pressing the button brings it to low. Moreover an analog sensor is connected to the analog pin A2 on the Arduino.

  • For the Green LED:  When the Arduino runs, it reads the value from the analog sensor connected to A2. This value is a measure of voltage that changes with the sensor’s readings. The Arduino then converts this reading to a corresponding brightness level for the green LED using analogWrite(), which uses pulse-width modulation (PWM) to simulate varying levels of brightness by quickly turning the LED on and off.
  • For the Red LED: The Arduino continuously reads the state of the pushbutton. When the button is detected as pressed (the signal on pin 2 goes from high to low due to the INPUT_PULLUP mode), it changes the blinking variable’s state. When blinking is true, the program  likely causes the red LED to turn on and off at certain intervals, simulating a blinking effect.

    Schematic Diagram Explanation:  Ultimately, the LEDs are represented by the symbols labeled ‘D1 GREEN’ and ‘D2 RED’. The resistors, labeled ‘R1’ and ‘R2’, are in series with the LEDs and connected to the digital pins on the Arduino symbol ‘U1’. The Arduino is central to the schematic and is labeled ‘U1’. All components are connected to it. It is shown with connections to power (5V and GND), the digital pins, and the analog pins. Hence the current flows from the 5V pin through the pushbutton when it is closed, and through the LEDs when they are enabled by the Arduino. Lastly this manages the flow by turning the pins to HIGH (5V) or LOW (0V) states and reading the voltage level from the analog sensor to determine the sensor’s readings.

Challenges and Reflection:
1) Connections of Jumper Wires: Connecting the wires to the action figure was a challenge because plastic tape doesn’t conduct electricity well. I had to ensure the ends of the jumper wires stayed firmly connected to the anode and cathode ends of the red LED without any loose connections. After some effort, I managed to secure the ends firmly with three to four pieces of tape.

2)  Push Button: The push button I used had a tendency to bounce (it has a loose connection with the bread board), causing unintended multiple presses. To solve this, first I implemented a delay in the code and they fixed the button with the help of screwdriver.

3) Photo-resistor Sensitivity and Range: The response of the photoresistor varied depending on the ambient light conditions. If the light levels fell outside the photo-resistor’s sensitive range, the LED wouldn’t respond as expected. To address this, initially I had to dim all the lights to make the room dark and I changed the range a bit limiting the sensor value from 400 to 250 then adjusted the code to accommodate my room lighting conditions, ensuring consistent LED performance.

Future Improvements:
a) I have an improvement in mind for the blinking green light in the background. Currently, it blinks manually with a delay of 250 ms. However, I want to integrate it with the background system so that when there’s a high pitch, the green background LED lights up brighter, and otherwise, it remains constantly low.

Overall, despite the hours spent on connections and coding, I’m satisfied with the outcome of the project. It feels completely worthwhile to recreate the scene of my favorite superhero from the comics! In the future, I’d love to enhance it further with more LEDs and sensors.

 

W10- Dual Lighting System Using Digital and Analog Sensors

As I am still experimenting with physical computing and coding for Arduino, I tried to emphasize simplicity for this week’s assignment. The concept for this week’s assignment is a simple lighting system using both digital and analog sensors. This lighting system has two LEDs, one attached to a manual system while the other an automatic one. This gives users the freedom to either choose to use only one light system or both. I was inspired to create this dual lighting system because I often feel like versatility in lighting is important not only to give a space more dimension but to also make our lives easier. With such a system, users are able to ensure that they have the right lighting for the circumstance they are in but also have the freedom to control it the way they see fit. Below you can find the schematic diagram of the system I created:

(warning, schematic diagram might not be comprehendible!)

After finalizing the schematic, I began building the actual system using the Arduino uno. The components used in this assignment were 11 wires, 2 LEDs, one button, one photo-resistor, 1 10K resistors, and 3 330 resistors. These components helped to create an efficient dual lighting system that helps users have a good balance between manual control and automatic adjustment of the lighting. I pinned the 5v and the ground to the positive and negative ends of the bread board to act as a “main ground” for the rest of the circuits on the bread board. For the button part of the circuit, I placed one end of the red wire to connect to the positive end of the board and one end of the 330 resistor. The other end of the 330 resistor is placed at the negative end of the bread board to ground it. The wire attached to 5v is attached to one end of the button, while the other end of the button is attached to pin 7. This wire is connected to another 330 resistor, which is attached to the LED A that is used for the “manual” system. The other end of LED A is grounded in the negative end of the bread board. For the photo-resistor, one end of it is attached to the positive end of the bread board where 5 voltage is. The other end of the photo-resistor is a wire that is attached to A1, which is an analog pin. That wire is connected to a 330 resistor. One side of the resistor connects to the wire that is connected to the negative end of the bread board where it is grounded. For LED B, which is the automatic part of the circuit, one side is connected to the negative end of the bread board where it is grounded and the other side is connected to a 330 resistor. The other end of the 330 resistor is connected to a wire, which is attached to pin 11. This makes the full manual and automatic light system. Below, you can find an image of the built system based off of the schematic diagram:


Programming the LEDs to function as intended required code for each. The first LED was programmed to turn on and remain on when the button was pressed and off and stay off when the button was pressed again, representing the digital sensor aspect of the system. The second LED was designed to activate and deactivate automatically in response to the light levels detected by the photo-resistor, which represents the analog sensor aspect of the system.  While the automatic adjustments based on the light levels might appear to be the most complex part of the system, it was actually the digital control of the first LED that presented the most challenges. I had to review class materials several times, go over examples, and watch youtube videos to get to the vision I wanted to have for this system. The youtube video that ultimately helped me to get to the vision I wanted was Robotics Back-End’s Arduino- Turn LED On and Off With Push Button video, which has been cited  at the bottom of this blog post. Therefore, that is one part of code that I am particularly proud of. 

void loop() {
//BUTTON
int buttonState = digitalRead (7);
// Check if enough time has passed since the last button state change
if (millis() - lastTimeButtonStateChanged >= debounceDuration){
   // Check if the button state has changed
  if (buttonState != lastButtonState){
    // Update the last time the button state changed
    lastTimeButtonStateChanged = millis();
    lastButtonState = buttonState;

    // Toggle the LED state when the button is pressed
    if (buttonState == LOW){ //If button is not pressed
      if (ledState == HIGH){ //and LED is on,
        ledState = LOW; //make LED turn on
      } else{ //if button is pressed,
        ledState = HIGH; //Make the LED turn on
      }
       // Update the LED controlled by the button
      digitalWrite(8, ledState);
   }
  }
 }
}

As you can see, the code corresponding to the button is intricate, utilizing a lot of ‘if’ statements to achieve the desired  on and off effect when the button is pressed. You can see this and the whole system in action below:  

In terms of improvements, I would have definitely liked to have only one LED to make it as similar to a typical light system as possible. I initially thought of coding one LED to have both the manual and automatic light systems but I, unfortunately, was not able to get it to function the way I wanted it to. Therefore, that is something I would like to improve on for the future. However, I have to say even with the countless days spent on this assignment, I genuinely enjoyed getting to the final product and seeing my vision come to life some way or another. As I mentioned earlier in this blog post, I was still adjusting to physical computing and using Arduino, which is why I wanted to create something simple. Creating this lighting system, although simple, was a big step into seeing not only the ways in which you can use physical computing components to create things that you envision but it has also allowed me to see the ways in which it can be used to fix real world problems. Even if this was obvious to me, it was only when I started to create things of my own did I see the potential and reach of physical computing in helping fix many of the problems people are facing today, which is something I am glad to have seen for myself. 

References: 

[Robotics Back-End]. (2022, February 28). Arduino – Turn LED On and Off With Push Button [Video]. Youtube. https://www.youtube.com/watch?v=ZoaUlquC6x8

Reading Reflection – Week 10

Physical Computing’s Greatest Hits (and Misses)

This reading was particularly informative, offering a wide array of projects within the field of physical computing. Previously, I had never imagined that such diverse and innovative projects were feasible when I first began my journey in this field. Particularly, I was fascinated by the idea of the theremin. This was a project I had wanted to work on when I was enrolled in another class last semester. However, due to my limited knowledge at the time, I couldn’t bring my ideas to reality. Now, equipped with the skills I’ve acquired from our recent classes, I feel confident and excited about the possibility of making this project a reality. The potential to combine electronic components with musical creativity truly captures the essence of what makes physical computing so exciting.

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

I really liked the directness and clarity in the title of the article. It reflects a fundamental truth about design: designers are communicators, not merely speakers. They show their thoughts through their creations. As the article discusses, Interactive Art goes beyond traditional boundaries by transforming viewers into active participants. This dynamic completes the artwork, creating a shared authorship between the creator and the audience. My experience last summer in a South Korean museum demonstrated this concept. There, I saw an interactive installation where visitors could draw animals and scan them to integrate their creations into the larger display with a pre-created background. This not only made the artwork dynamic but also personal, as each visitor’s contribution became central to the artistic narrative. It was a vivid demonstration of the profound connection that interactive art can forge, drawing beauty from the synergy between the artist’s vision and the audience’s involvement.

Week 10 | Creative Reading Response

“Physical Computing’s Greatest Hits ” was a very interesting and thought provoking article . It talks about different forms of Interactive projects related to physical computing . Several interesting ideas were presented . It provoked me to think about ideas for my IM Final project. Ideas such as the hands-as-cursor and the glove are really interesting to me and I hope I can build something inspired by them for my Final Project. Ideas like these that turn the human hand into a method for controlling an object or a screen is something I would love to work on . 

“Making Interactive Art” focuses more on the role of us as designers to create an experience of discovery for the user .The idea that the main goal is not to create an entire conversation but rather to start a conversation is something I would like to keep in mind while designing something interactive . This ties well with the idea of signifiers by Don Norman in the previous readings.  The idea of art that inspires rather than conveys has always been appealing to me. This notion of taking the user through a journey rather than specifying a fixed way of interacting with the work reminds me of the phrase “The journey is more beautiful than the destination ” . I hope to keep this in mind in my upcoming projects . 

Week 10: Response on Physical Computing and Interactive Art Readings

Physical Computing Greatest Hits and Misses

I agree with the author’s description in the article that when someone is learning physical computing and is required to come up with project ideas, people sometimes just eliminate most of the ideas just because they thought that it has already been done before. While there is plenty of room for variety and enhancement, it can lead to an entirely new concept. In short, I found the author’s insight firmly aligned with the concept of ‘standing on the shoulders of giants’. And I think this is an amazing realization that one must have since innovation always comes out when individuals stole the ideas that are worth stealing and left behind others that are not attractive to them and then built something that is entirely new.

Two interesting technologies that were mentioned in this article that I like the most were the Gloves and the Hand-as-cursor. The way the drum gloves are designed on the interface of the gestural language, producing discrete musical notes though simple finger taps shows the integration of force-sensing resistors and flex sensors in the Power Glove to detect movement and gestures. This idea seems to be intriguing yet complex, as it captures the challenge of translating simple, intuitive human actions. I believe the complexity is not only in the technological implementation but also in ensuring that the user experience remains interesting and simple. This technical conversation causes me to reflect critically on the balance between technology and the simplicity required for widespread user acceptance. This thinking leads me to draw parallels with the evolution of touchscreen technology, particularly its incorporation into mobile devices. Initially, touch screens were a novel technology that some saw as gimmicky; nevertheless, their design centered on natural human actions, such as swiping and tapping, which led to widespread adoption. This “intertext” identifies a vital path for me from innovation to integration, underlining the necessity of user-centered design in technology.

Despite the advances these themes represent, they raise concerns about the extent to which such interfaces can replace more traditional input modalities such as keyboards and mice, which continue to provide unrivaled precision for particular activities. This makes me wonder about the future development of glove and hand-tracking technology. Could they employ haptic feedback to provide a tangible response to digital interactions, thereby increasing user engagement and control?

Making interactive Art: Set the Stage, Then shut up and Listen

This article introduced me to a new idea that I had never considered before. Because things were never taught that way before. In any classes that I have attended up to this point that involved interactive artwork creation or even ideation, I have always felt the need to describe what my artwork is supposed to do while you are experiencing it. While I had the opportunity, I came across what I call Freestyle art projects, in which the students creating the project choose the elements, randomize them, and then hold those elements responsible for the user’s experience. This is similar to what the author is attempting to say: let the audience grasp it on their own. But I was never convinced by this approach before; I believe that if you are unable to demonstrate and let the person on the other end comprehend what you truly created, you have not done your job effectively. But I believe the author’s perspective on this has persuaded me to think otherwise when he says — ‘if you’re thinking of an interactive artwork, don’t think of it like a finished painting or sculpture. Think of it more as a performance. Your audience completes the work through what they do when they see what you’ve made.’

Reading Reflections- Week 10 (2 Readings)

Physical Computing’s Greatest Hits (and misses)

As I read about the common themes in physical computing, I was amazed by the variety of projects possible in this field. Each idea seemed to offer its own unique possibilities for creativity and learning.

One theme that particularly caught my attention was the concept of theremin-like instruments. As a musician myself, the idea of creating music through physical gestures rather than traditional methods intrigued me, especially considering the simplicity of the setup. However, I couldn’t help but wonder about the potential for incorporating more complex gestures or interactions to enhance the musical experience further. Another interesting theme was using video mirrors to reflect movements. While this sounded cool, I wondered if there were ways to make these projects more engaging beyond just reflecting movements. I was also intrigued by the idea of mechanical pixels, where small parts move to create artwork. It sounded challenging but exciting. I wondered how artists could use this technique to tell stories or convey emotions.

Overall, I was struck by the balance between simple and complex projects in physical computing. Some ideas were easy to understand, while others seemed more intricate. I’m excited to explore these concepts further and see what new ideas I can come up with!

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

Reading this article about making interactive art really changed how I see my role as an artist. Instead of just expressing myself, I now understand that my art can be a conversation with the people who experience it. I learned that I should set the stage for interaction without telling people what to think or do. It’s like creating a performance where the audience completes the work through their actions.

I realized that I tend to explain my art too much, which can limit how people engage with it. Now, I want to give the audience space to form their own interpretations. I’m curious about how I can use performance and interactivity to make my art more engaging. I think it’s important to listen to the audience’s reactions and learn from them to improve my future projects.

This article inspired me to take a more collaborative approach to my art. I want to create pieces that encourage people to participate and explore, while still conveying my message. I’m excited to experiment with new ideas and see how they resonate with viewers.

Week 9 – 2 readings

Physical Computing’s Greatest Hits (and misses)

It became clear to me after reading “Physical Computing’s Greatest Hits (and misses)” that old concepts in physical computing may be updated to create something fresh and innovative. The piece goes through a number of projects, such as interactive pads and musical instruments, to demonstrate how amazing inventions can result from reimagining old concepts in fresh ways. It’s a fun reminder that often the most innovative ideas are simply the greatest old ones with a little tweaking.

I was particularly drawn to three items, which caused me to reconsider my previous thoughts. I was first shown that you are not limited to traditional methods of creating music by experimenting with making music with movements, such as with theremin-like devices. This helped me to see how our creative expression can be altered by actual computers. Second, the combination of digital technology with real-world artifacts to create images made “Mechanical Pixels” quite fascinating. This innovative approach to digital pictures gives it a more vibrant, more engaging feeling. Last but not least, the section on “Multitouch Interfaces” got me to reflect on how we utilize technology. It brought to light that, despite its coolness, touchscreens fail to provide us with tactile feedback—a crucial feature. This got me thinking about how gadgets could be more user-friendly.

I have to reconsider my definition of innovation in physical computing after reading this paper. It demonstrated to me the value of updating classic concepts and the necessity of maintaining an open mind regarding our interactions with technology.

 

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

The book “Making Interactive Art: Set the Stage, Then Shut Up and Listen” changed my understanding of interactive art, highlighting the crucial function viewers play in deciphering and finally finishing the piece. The idea that interactive art should be a dialogue between the creator and the viewer, where the latter’s interaction brings the piece to fruition, is something this article helped me completely understand. This method suggested a more freeing perspective where art is accessible to individual interpretation and discovery, which contradicted my preconceived assumptions about the artist’s responsibility in influencing the audience’s interpretation.

The painting made me think about the fine line that artists have to walk when it comes to giving their work just the right amount of context. This thought piqued my interest in the ways in which artists might create experiences that are both approachable and captivating without being unduly prescriptive in how they direct audience participation. The essay made a significant point regarding the need for artists to carefully analyze their approach to audience engagement, even though it didn’t go into great detail about how to achieve this balance.

After thinking back on my own experiences as a participant and creator of interactive art, I realized that the article’s observations aligned with the more fruitful elements of previous endeavors. In many cases, giving the audience the latitude to explore and participate with the work at their own pace resulted in more significant and profound audience participation. This insight encourages a move toward more open-ended interaction that welcomes individual investigation and interpretation. It also challenges me to reevaluate how I communicate my work. All things considered, this discovery validates the article’s thesis.

The author’s perspective is objective and encourages a wide range of interpretations, even though it presents a definite opinion on the significance of audience participation in interactive art. The essay gives artists the freedom to explore different approaches to inviting audience interaction and response, without taking a prescriptive stand on what interactive art has to be.

“Making Interactive Art: Set the Stage, Then Shut Up and Listen” questioned my preconceptions about the directive role of the artist and provided me with a fresh perspective on interactive art, which will help me in my future endeavors. It brought to light the dynamic and cooperative relationship that exists between the artist, the piece of art, and the audience. This has inspired artists to create art that genuinely involves viewers as active participants in the creative process.

 

 

Week 9 – BrightSafe: The Dual-Mode Lighting Guardian

BrightSafe: The Dual-Mode Lighting Guardian

Concept:

My idea, which focuses on house safety and comfort. My code cleverly models a dual lighting system that mimics real-life conditions. The green LED functions as a depiction of “normal life” lighting, changing its brightness dependent on ambient light and producing illumination that closely resembles natural light conditions throughout the day. As the sun goes down the house will receive less light. Conversely, the red LED functions as an emergency light and is managed by a straightforward switch. It is not dependent on the level of ambient light. This arrangement guarantees that residents will have a dependable source of manually activated light providing a safety and convenient light in unforeseen circumstances.

 

Code:

const int ledPinRed = 9;      // Digital LED pin
const int ledPinGreen = 10;   // Analog LED pin 
const int buttonPin = 2;      // Pushbutton pin
const int ldrPin = A0;        // Photoresistor pin

void setup() {
  pinMode(ledPinRed, OUTPUT);
  pinMode(ledPinGreen, OUTPUT);
  pinMode(buttonPin, INPUT_PULLUP); // Enable internal pull-up
  Serial.begin(9600); 
}

void loop() {
  int ldrValue = analogRead(ldrPin); // Read the light level
  int brightness = map(ldrValue, 0, 1023, 0, 255); // Map to PWM range
  analogWrite(ledPinGreen, brightness); // Set brightness of green LED

  // Check if button is pressed (LOW when pressed due to pull-up resistor)
  if (digitalRead(buttonPin) == LOW) {
    digitalWrite(ledPinRed, HIGH); // Turn on red LED
  } else {
    digitalWrite(ledPinRed, LOW); // Turn off red LED
  }


}

Project: 

https://youtube.com/shorts/w3vne8FGQ2k?feature=share

Difficulties: 

I had a hard time connecting the wires to the Arduino as the holes were very small. Also having to write down the code was the most challenging as I’m still not comfortable with this language

Improvements:

My idea is to improve the system by using a separate battery to power the red light. With this improvement, safety lighting is guaranteed to continue even in the event of a power outage, replacing traditional power sources.

Week 9 – Unusual switch – PCGuard

Concept – PCGuard

Nowadays people spend a lot of time on their computers. I wanted to create a switch that rewarded users for closing their laptops. The name of my project clearly reflects its use. PC = computer and Guard = police/close it

Process 

I used: a green LED, 330 resistor, wires, blue-tack, and my computer.

Project

Reflection

I am excited to have created this switch. In the beginning, I was a bit stuck as I did not know where to attach my switch to. Now I have gone through all the class slides and done all the exercises and I am feeling more comfortable as I understand a bit better how this system works. 😉

Improvements

I would like when the computer closed the light turned on and a sound (victory music) turned on. It would add interaction and an increased feel of reward.

Assignment 6: Digital & Analog Sensor

Concept

The concept of this assignment is traffic light. In the circuit, I used red, yellow, and green LEDs to mimic the traffic light. The red and yellow LED turns on when the button is pressed and off when the button is not pressed. The green light changes its dimness according to the potentiometer. Many drivers often wish the green light to be on for a long time so that they can drive continuously through the traffic lights. So I used the potentiometer to let the green LED stay on with full dimness when all of 5V is supplied.

Code & Sketch

When creating the circuit, I focused on building the digital circuit first and then the analog circuit. In this way, I did not confuse myself and was able to make sure each component worked.

I referenced the design of the circuit for the potentiometer that I learned in class (the sketch is displayed below). Along with the design of the circuit for the potentiometer or the analog sensor, I used a very simple design for the button or the digital sensor. For both designs, I used a 330 ohm resistor because using a 10K ohm resistor was unnecessary.

Below is the code for the entire circuit. I only coded for the potentiometer because Arduino code was not needed to activate the button. The code for running the potentiometer is very simple. I initially defined a variable ‘led’ and used sensorValue to determine the brightness of the LED. I used PWM pin 11 to activate the brightness effect and delay to make the dimness effect visible.

int led = 11;

void setup() {

  Serial.begin(9600);

  //pin 11 output
  pinMode(led, OUTPUT);

}

void loop() {

  int sensorValue = analogRead(A2);
  Serial.println(sensorValue);

  // set the brightness of pin 11 according to the sensorValue and divided by 4
  analogWrite(led, sensorValue/4);

  // delay effect for 30 milliseconds to see the change in dimness
  delay(30);

}

Reflection

Creating the circuit was not difficult because most of it was materials covered in class. However, if I had to mention one slightly challenging thing, I would say it is working with tiny materials. My hand was comparatively larger than all the elements and trying to place them on the breadboard, I had to be careful to not misplace or interrupt the other elements already positioned on the breadboard.

To add on, when I first thought of this assignment, I wanted to have separate buttons for the red and yellow LEDs. However, due to the limited space on the breadboard, I was not able to do so. Therefore, for improvement, I would like to readjust the position of the elements on the breadboard so that I can fit one more button for the LED and be able to control the red and yellow LED separately.

Outcome

How the circuit works