Arduino: analog input & output- Elyazia Abbas

Concept:

For this week’s assignment, I made the Plant Care Assistant. It helps users monitor their plant’s water needs through simple visual feedback. A green LED will light up when the sun exposure is high(simulate with flashlight from phone). A red LED will light up when the sun exposure is low(simulate with moving away flashlight from phone). When users click the yellow button, if it flashes yellow, then the plant is in good state and if it does not flash at all, the plant needs to be taken care of.

Code:

int ledFlashOn = 11;   // led on pin 11 flashes if the plant has enough sunlight
int ledFlashOff = 12;  // led on pin 12  flash red if the plant doesn has enough sunlight
int sensorPin = A2; //sensor pin for the light sensor 

void setup() {
  Serial.begin(9600);
  pinMode(ledFlashOn, OUTPUT);
  pinMode(ledFlashOff, OUTPUT);
}

void loop() {
  int sensorValue = analogRead(sensorPin); //gettign the value of the pin 
  Serial.println(sensorValue); //printing t in the serial monitor

  if (sensorValue > 950) { //if sensor value is greater than 950 
    digitalWrite(ledFlashOn, HIGH); //light up green dont light up red
    digitalWrite(ledFlashOff, LOW);
  } else {
//light up red dont light up green   
    digitalWrite(ledFlashOff, HIGH);
  }

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

In my Arduino code we continuously read analog values from a light sensor connected to pin A2, where higher values indicate more light. When the sensor reading exceeds 950 (bright sunlight), the code turns on the green LED on pin 11 while keeping the red LED on pin 12 off, signaling that the plant is receiving adequate sunlight. If the reading falls below 950, it switches to illuminate the red LED while turning off the green one, warning that the plant needs more light. The serial monitor displays real-time sensor readings for debugging, and a 50ms delay ensures stable readings without flickering.

Hand-Drawn Schematic:

Reflections & Future Improvements:

For future improvements, I’d like to add PWM control to make the LEDs fade in and out for smoother transitions between states, and implement multiple thresholds to show “perfect,” “okay,” and “needs more light” zones instead of just binary feedback. Adding a data logging feature to track light exposure over time would help understand the plant’s daily light patterns.

Reading Reflection:

One example that stood out to me was the drum glove project. It transforms the familiar act of tapping one’s fingers into a musical interface, blending intuitive human gesture with technology. I found this especially interesting because it captures the essence of Igoe’s argument which is:  it doesn’t dictate what the user should feel or do, it just invites them to explore sound through motion. Through this glove creativity emerges from the user’s spontaneous actions rather than the artist’s fixed script. Both readings remind me that successful interactive art balances structure and openness, designing just enough to spark imagination, but never enough to silence it.

Leave a Reply