Raya Tabassum: Emotional Room Temperature Indicator

Concept: This project combines analog and digital inputs to control LEDs in an innovative way. It’s an “Emotional Room Temperature Indicator”, which uses temperature data and user input to reflect the room’s “mood” with light.

Components Used:

  • Arduino Uno
  • TMP36 Temperature Sensor (Analog Sensor)
  • Push-button switch (Digital Sensor)
  • Standard LED (Digital LED)
  • RGB LED (Analog LED)
  • 220-ohm resistors for LEDs
  • 10k-ohm resistor for the button switch
  • Breadboard
  • Jumper wires

Implementation: I made a reel with description and uploaded as a YouTube shorts embedded below:

Programming:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
#define LED_PIN 3
#define BUTTON_PIN 7
int redPin = 9;
int greenPin = 10;
int bluePin = 11;
int sensor = A0;
byte lastButtonState = LOW;
byte ledState = LOW;
unsigned long debounceDuration = 50; // millis
unsigned long lastTimeButtonStateChanged = 0;
void setup() {
pinMode(LED_PIN, OUTPUT);
pinMode(BUTTON_PIN, INPUT);
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
pinMode(sensor, INPUT); // Reading sensor data
Serial.begin(9600); // Initialize serial communication at 9600 bits per second
}
int givetemp() {
int reading = analogRead(sensor);
float voltage = reading * 5.0 / 1024.0;
float temperatureC = (voltage - 0.5) * 100;
Serial.print(voltage);
Serial.print(" volts - ");
Serial.print(temperatureC);
Serial.println(" degrees C - ");
return (int)temperatureC; // Convert float temperature to int before returning
}
void loop() {
int currentTemp = givetemp(); // Call once and use the result multiple times
if (currentTemp >= 20 && currentTemp <= 30) {
digitalWrite(greenPin, HIGH);
digitalWrite(bluePin, LOW);
digitalWrite(redPin, LOW);
} else if (currentTemp < 20) {
digitalWrite(greenPin, LOW);
digitalWrite(bluePin, HIGH);
digitalWrite(redPin, LOW);
} else if (currentTemp > 30) {
digitalWrite(greenPin, LOW);
digitalWrite(bluePin, LOW);
digitalWrite(redPin, HIGH);
}
if (millis() - lastTimeButtonStateChanged > debounceDuration) {
byte buttonState = digitalRead(BUTTON_PIN);
if (buttonState != lastButtonState) {
lastTimeButtonStateChanged = millis();
lastButtonState = buttonState;
if (buttonState == HIGH) { // Assumes active HIGH button
ledState = !ledState; // Toggle the state
digitalWrite(LED_PIN, ledState);
}
}
}
}
#define LED_PIN 3 #define BUTTON_PIN 7 int redPin = 9; int greenPin = 10; int bluePin = 11; int sensor = A0; byte lastButtonState = LOW; byte ledState = LOW; unsigned long debounceDuration = 50; // millis unsigned long lastTimeButtonStateChanged = 0; void setup() { pinMode(LED_PIN, OUTPUT); pinMode(BUTTON_PIN, INPUT); pinMode(redPin, OUTPUT); pinMode(greenPin, OUTPUT); pinMode(bluePin, OUTPUT); pinMode(sensor, INPUT); // Reading sensor data Serial.begin(9600); // Initialize serial communication at 9600 bits per second } int givetemp() { int reading = analogRead(sensor); float voltage = reading * 5.0 / 1024.0; float temperatureC = (voltage - 0.5) * 100; Serial.print(voltage); Serial.print(" volts - "); Serial.print(temperatureC); Serial.println(" degrees C - "); return (int)temperatureC; // Convert float temperature to int before returning } void loop() { int currentTemp = givetemp(); // Call once and use the result multiple times if (currentTemp >= 20 && currentTemp <= 30) { digitalWrite(greenPin, HIGH); digitalWrite(bluePin, LOW); digitalWrite(redPin, LOW); } else if (currentTemp < 20) { digitalWrite(greenPin, LOW); digitalWrite(bluePin, HIGH); digitalWrite(redPin, LOW); } else if (currentTemp > 30) { digitalWrite(greenPin, LOW); digitalWrite(bluePin, LOW); digitalWrite(redPin, HIGH); } if (millis() - lastTimeButtonStateChanged > debounceDuration) { byte buttonState = digitalRead(BUTTON_PIN); if (buttonState != lastButtonState) { lastTimeButtonStateChanged = millis(); lastButtonState = buttonState; if (buttonState == HIGH) { // Assumes active HIGH button ledState = !ledState; // Toggle the state digitalWrite(LED_PIN, ledState); } } } }
#define LED_PIN 3
#define BUTTON_PIN 7
int redPin = 9; 
int greenPin = 10; 
int bluePin = 11;
int sensor = A0;

byte lastButtonState = LOW;
byte ledState = LOW;

unsigned long debounceDuration = 50; // millis
unsigned long lastTimeButtonStateChanged = 0;

void setup() {
  pinMode(LED_PIN, OUTPUT);
  pinMode(BUTTON_PIN, INPUT);
  pinMode(redPin, OUTPUT); 
  pinMode(greenPin, OUTPUT); 
  pinMode(bluePin, OUTPUT); 
  pinMode(sensor, INPUT);  // Reading sensor data

  Serial.begin(9600);  // Initialize serial communication at 9600 bits per second
}

int givetemp() {
  int reading = analogRead(sensor);
  float voltage = reading * 5.0 / 1024.0;
  float temperatureC = (voltage - 0.5) * 100;
  Serial.print(voltage); 
  Serial.print(" volts  -  ");
  Serial.print(temperatureC); 
  Serial.println(" degrees C  -  ");
  return (int)temperatureC;  // Convert float temperature to int before returning
}

void loop() {
  int currentTemp = givetemp();  // Call once and use the result multiple times

  if (currentTemp >= 20 && currentTemp <= 30) {
    digitalWrite(greenPin, HIGH);
    digitalWrite(bluePin, LOW);
    digitalWrite(redPin, LOW);
  } else if (currentTemp < 20) {
    digitalWrite(greenPin, LOW);
    digitalWrite(bluePin, HIGH);
    digitalWrite(redPin, LOW);
  } else if (currentTemp > 30) {
    digitalWrite(greenPin, LOW);
    digitalWrite(bluePin, LOW);
    digitalWrite(redPin, HIGH);
  }

  if (millis() - lastTimeButtonStateChanged > debounceDuration) {
    byte buttonState = digitalRead(BUTTON_PIN);
    if (buttonState != lastButtonState) {
      lastTimeButtonStateChanged = millis();
      lastButtonState = buttonState;
      if (buttonState == HIGH) {  // Assumes active HIGH button
        ledState = !ledState;  // Toggle the state
        digitalWrite(LED_PIN, ledState);
      }
    }
  }
}

Actual temperature of the room:

The TMP36 senses the room temperature. Depending on the “comfort” range (set here as 20°C to 30°C), the RGB LED changes colors — blue for cool, red for hot, and green for just right.
The push-button allows the user to set the mood of the room. When pressed, the standard yellow LED lights up to acknowledge that the room is at a comfortable temperature, while the RGB LED shows the current temperature-based mood of the room. The user can thus get immediate visual feedback on whether the room’s temperature is within a comfortable range or not.

Week #10 Assignment

Concept: 
For this assignment, I decided to implement the things that I have already learned in regards to the ultrasonic sensor and add the button. I wanted to see how far I can go with my knowledge.
Implementation:
The implementation was pretty easy, as I have used the previous assignment as an example. I just added the button and changed the code and voila!
End result:

Code:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
//Intro to IM - Stefania Petre
// Define LED pins
int ledPin[3] = {8};
// Define Ultrasonic sensor pins
const int trigPin = 2; // or any other unused digital pin
const int echoPin = 3; // or any other unused digital pin
const int buttonPin = 13;
int buttonState = HIGH;
int lastButtonState = HIGH;
long lastDebounceTime = 0;
long debounceDelay = 50;
int pushCounter = 0;
int numberOfLED = 3;
void setup() {
pinMode(buttonPin, INPUT);
digitalWrite(buttonPin, HIGH); // Activate internal pull-up resistor
// Set up LED pins
for (int i = 0; i < numberOfLED; i++) {
pinMode(ledPin[i], OUTPUT);
}
// Set up Ultrasonic sensor pins
pinMode(trigPin, OUTPUT); // Sets the trigPin as an OUTPUT
pinMode(echoPin, INPUT); // Sets the echoPin as an INPUT
}
void loop() {
int reading = digitalRead(buttonPin);
// Check if the button state has changed
if (reading != lastButtonState) {
// Reset the debounce timer
lastDebounceTime = millis();
}
// Check if the debounce delay has passed
if ((millis() - lastDebounceTime) > debounceDelay) {
// If the button state has changed, update the button state
if (reading != buttonState) {
buttonState = reading;
// If the button state is LOW (pressed), increment pushCounter
if (buttonState == LOW) {
pushCounter++;
}
}
}
// Update the last button state
lastButtonState = reading;
// Turn off LED
for (int i = 0; i < numberOfLED; i++) {
digitalWrite(ledPin[i], LOW);
}
// Perform Ultrasonic sensor reading
long duration, distance;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration * 0.0343) / 2; // Calculate distance in cm
// Perform actions based on distance measured
if (distance < 30) {
// Turn on LED
digitalWrite(ledPin[0], HIGH);
// Delay before next iteration
delay(100); // Adjust as needed
}
//Intro to IM - Stefania Petre // Define LED pins int ledPin[3] = {8}; // Define Ultrasonic sensor pins const int trigPin = 2; // or any other unused digital pin const int echoPin = 3; // or any other unused digital pin const int buttonPin = 13; int buttonState = HIGH; int lastButtonState = HIGH; long lastDebounceTime = 0; long debounceDelay = 50; int pushCounter = 0; int numberOfLED = 3; void setup() { pinMode(buttonPin, INPUT); digitalWrite(buttonPin, HIGH); // Activate internal pull-up resistor // Set up LED pins for (int i = 0; i < numberOfLED; i++) { pinMode(ledPin[i], OUTPUT); } // Set up Ultrasonic sensor pins pinMode(trigPin, OUTPUT); // Sets the trigPin as an OUTPUT pinMode(echoPin, INPUT); // Sets the echoPin as an INPUT } void loop() { int reading = digitalRead(buttonPin); // Check if the button state has changed if (reading != lastButtonState) { // Reset the debounce timer lastDebounceTime = millis(); } // Check if the debounce delay has passed if ((millis() - lastDebounceTime) > debounceDelay) { // If the button state has changed, update the button state if (reading != buttonState) { buttonState = reading; // If the button state is LOW (pressed), increment pushCounter if (buttonState == LOW) { pushCounter++; } } } // Update the last button state lastButtonState = reading; // Turn off LED for (int i = 0; i < numberOfLED; i++) { digitalWrite(ledPin[i], LOW); } // Perform Ultrasonic sensor reading long duration, distance; digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); distance = (duration * 0.0343) / 2; // Calculate distance in cm // Perform actions based on distance measured if (distance < 30) { // Turn on LED digitalWrite(ledPin[0], HIGH); // Delay before next iteration delay(100); // Adjust as needed }
//Intro to IM - Stefania Petre
// Define LED pins
int ledPin[3] = {8};

// Define Ultrasonic sensor pins
const int trigPin = 2; // or any other unused digital pin
const int echoPin = 3; // or any other unused digital pin

const int buttonPin = 13;
int buttonState = HIGH;
int lastButtonState = HIGH;
long lastDebounceTime = 0;
long debounceDelay = 50;
int pushCounter = 0;
int numberOfLED = 3;

void setup() {
  pinMode(buttonPin, INPUT);
  digitalWrite(buttonPin, HIGH); // Activate internal pull-up resistor
  
  // Set up LED pins
  for (int i = 0; i < numberOfLED; i++) {
    pinMode(ledPin[i], OUTPUT);
  }
  
  // Set up Ultrasonic sensor pins
  pinMode(trigPin, OUTPUT); // Sets the trigPin as an OUTPUT
  pinMode(echoPin, INPUT);  // Sets the echoPin as an INPUT
}

void loop() {
  int reading = digitalRead(buttonPin);

  // Check if the button state has changed
  if (reading != lastButtonState) {
    // Reset the debounce timer
    lastDebounceTime = millis();
  }

  // Check if the debounce delay has passed
  if ((millis() - lastDebounceTime) > debounceDelay) {
    // If the button state has changed, update the button state
    if (reading != buttonState) {
      buttonState = reading;

      // If the button state is LOW (pressed), increment pushCounter
      if (buttonState == LOW) {
        pushCounter++;
      }
    }
  }

  // Update the last button state
  lastButtonState = reading;

  // Turn off LED
  for (int i = 0; i < numberOfLED; i++) {
    digitalWrite(ledPin[i], LOW);
  }

  // Perform Ultrasonic sensor reading
  long duration, distance;
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration * 0.0343) / 2; // Calculate distance in cm

  // Perform actions based on distance measured
  if (distance < 30) {
    // Turn on LED
    digitalWrite(ledPin[0], HIGH);
 

  // Delay before next iteration
  delay(100); // Adjust as needed
}

Comments:

Even though I got it to work, I still would have liked it to change colors depending on the distance from the sensor. I will try to implement that next time!

Week 10 Production Assignment – Tea Temperature

For this week’s production assignment I wanted to experiment with a component that I have not yet used. The one component I had in mind for this was the temperature sensor. As I enjoy drinking tea, I decided to implement a circuit which gauges the presence and temperature of a liquid.

In order to do this, I created a series of if statements that test the temperature read by the sensor. While the technical aspect of this was manageable, the practical side was challenging. This was due to the unreliability of the sensor as it would read fluctuating and incorrect temperatures. Despite this, I was able to get some successful examples by restarting the circuit (and therefore restarting the sensor’s input). This is seen in the example below. The if statements are included below as well.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
const int rgbRED_PIN = 9;//the digital pin for red pin
const int rgbGREEN_PIN = 10;//the digital pin for green pin
const int rgbBLUE_PIN = 11;//the digital pin for blue pin
const int temperaturePin = 0;//the analog read pin that is used to reat the temperature
const int waterPin = 12;
const int greenLED_Pin = 13;
void setup()
{
pinMode(rgbRED_PIN, OUTPUT);
pinMode(rgbGREEN_PIN, OUTPUT);
pinMode(rgbBLUE_PIN, OUTPUT);
pinMode(waterPin, INPUT);
pinMode(greenLED_Pin, OUTPUT);
Serial.begin(9600);//the bound rate for serial monitor
}
void loop()
{
int waterDetected = digitalRead(waterPin);
if (waterDetected == HIGH) {
digitalWrite(greenLED_Pin, HIGH);
} else {
digitalWrite(greenLED_Pin, LOW);
}
float voltage, degreesC, degreesF;//get numbers with decimals
voltage = getVoltage(temperaturePin);//get voltage from the temperature pin
degreesC = (voltage - 0.5) * 100.0;//calculate the celcius degree
degreesF = degreesC * (9.0/5.0) + 32.0;// calculate the Fahrenheit degree
Serial.print("voltage: ");//print volrage in serial monitor
Serial.print(voltage);
Serial.print(" deg C: ");//print the celcious degree in serial monitor
Serial.println(degreesC);
if (degreesC < 23) //if the temperature is less than 23 degrees C turn off RGB
{
// Off (all LEDs off):
digitalWrite(rgbRED_PIN, LOW);
digitalWrite(rgbGREEN_PIN, LOW);
digitalWrite(rgbBLUE_PIN, LOW);
}
if (degreesC >= 24)//if the temperature is larger than 24 degrees C show purple
{
digitalWrite(rgbRED_PIN, HIGH);
digitalWrite(rgbGREEN_PIN, LOW);
digitalWrite(rgbBLUE_PIN, HIGH);
}
}
float getVoltage(int pin)//get voltage
{
return (analogRead(pin) * 0.004882814);// conver 0 to 1023 value to 0 to 5 value (the true voltage)
}
const int rgbRED_PIN = 9;//the digital pin for red pin const int rgbGREEN_PIN = 10;//the digital pin for green pin const int rgbBLUE_PIN = 11;//the digital pin for blue pin const int temperaturePin = 0;//the analog read pin that is used to reat the temperature const int waterPin = 12; const int greenLED_Pin = 13; void setup() { pinMode(rgbRED_PIN, OUTPUT); pinMode(rgbGREEN_PIN, OUTPUT); pinMode(rgbBLUE_PIN, OUTPUT); pinMode(waterPin, INPUT); pinMode(greenLED_Pin, OUTPUT); Serial.begin(9600);//the bound rate for serial monitor } void loop() { int waterDetected = digitalRead(waterPin); if (waterDetected == HIGH) { digitalWrite(greenLED_Pin, HIGH); } else { digitalWrite(greenLED_Pin, LOW); } float voltage, degreesC, degreesF;//get numbers with decimals voltage = getVoltage(temperaturePin);//get voltage from the temperature pin degreesC = (voltage - 0.5) * 100.0;//calculate the celcius degree degreesF = degreesC * (9.0/5.0) + 32.0;// calculate the Fahrenheit degree Serial.print("voltage: ");//print volrage in serial monitor Serial.print(voltage); Serial.print(" deg C: ");//print the celcious degree in serial monitor Serial.println(degreesC); if (degreesC < 23) //if the temperature is less than 23 degrees C turn off RGB { // Off (all LEDs off): digitalWrite(rgbRED_PIN, LOW); digitalWrite(rgbGREEN_PIN, LOW); digitalWrite(rgbBLUE_PIN, LOW); } if (degreesC >= 24)//if the temperature is larger than 24 degrees C show purple { digitalWrite(rgbRED_PIN, HIGH); digitalWrite(rgbGREEN_PIN, LOW); digitalWrite(rgbBLUE_PIN, HIGH); } } float getVoltage(int pin)//get voltage { return (analogRead(pin) * 0.004882814);// conver 0 to 1023 value to 0 to 5 value (the true voltage) }
const int rgbRED_PIN = 9;//the digital pin for red pin
const int rgbGREEN_PIN = 10;//the digital pin for green pin
const int rgbBLUE_PIN = 11;//the digital pin for blue pin
const int temperaturePin = 0;//the analog read pin that is used to reat the temperature 
const int waterPin = 12;  
const int greenLED_Pin = 13;
 
void setup()
{
 
  pinMode(rgbRED_PIN, OUTPUT);
  pinMode(rgbGREEN_PIN, OUTPUT);
  pinMode(rgbBLUE_PIN, OUTPUT);
  pinMode(waterPin, INPUT);
  pinMode(greenLED_Pin, OUTPUT);
  Serial.begin(9600);//the bound rate for serial monitor 
  
}
 
 
void loop()
{
 
   int waterDetected = digitalRead(waterPin);
     if (waterDetected == HIGH) {
    digitalWrite(greenLED_Pin, HIGH);
  } else {
    digitalWrite(greenLED_Pin, LOW);
  }

  float voltage, degreesC, degreesF;//get numbers with decimals 
 
  voltage = getVoltage(temperaturePin);//get voltage from the temperature pin
  degreesC = (voltage - 0.5) * 100.0;//calculate the celcius degree
  degreesF = degreesC * (9.0/5.0) + 32.0;// calculate the Fahrenheit degree
 
  Serial.print("voltage: ");//print volrage in serial monitor
  Serial.print(voltage);
  Serial.print("  deg C: ");//print the celcious degree in serial monitor
  Serial.println(degreesC);
 
 
  if (degreesC < 23) //if the temperature is less than 23 degrees C turn off RGB
  {
  // Off (all LEDs off):
    digitalWrite(rgbRED_PIN, LOW);
    digitalWrite(rgbGREEN_PIN, LOW);
    digitalWrite(rgbBLUE_PIN, LOW);
  }
 
  
if (degreesC >= 24)//if the temperature is larger than 24 degrees C show purple
  {
  digitalWrite(rgbRED_PIN, HIGH);
  digitalWrite(rgbGREEN_PIN, LOW);
  digitalWrite(rgbBLUE_PIN, HIGH);
  }
}
 
 
 
float getVoltage(int pin)//get voltage 
 
 {
  return (analogRead(pin) * 0.004882814);// conver 0 to 1023 value to 0 to 5 value (the true voltage)
 }

 

One point that I could not manage was the water detection aspect which I wanted to incorporate into this circuit. I attempted to do so by connecting alligator clips into a cup of water in order to complete the circuit. The LED would flicker occasionally but would not stay on consistently. I am unsure whether this is due to the connection of the alligator clips (other examples I have seen use regular wires) or because of the way I had wired the circuit itself.

Week 10 – Assignment

The project is designed as a competitive game using an Arduino board to determine who can activate their respective LED faster: a player pressing a button or an automated response triggered by a photoresistor detecting darkness. The setup includes two LEDs connected to the Arduino. One LED (connected to pin 10) is controlled by a pushbutton, which, when pressed, signifies the  player’s reaction. The other LED (connected to pin 9) is controlled by a photoresistor, representing an automated “player” that reacts to the absence of light. The game’s objective is to see which mechanism can activate its LED first under the given conditions—either when it becomes dark enough for the photoresistor to react or when the human player presses the button.

This was a lot of fun to make and the concept sort of formed as I put everything together, I mostly focused on using the class notes as a resources however I did use some of the examples on the official Arduino website. 

https://forum.arduino.cc/t/using-an-led-and-a-photoresistor-to-switch-itself-on-and-off/179690

https://projecthub.arduino.cc/agarwalkrishna3009/arduino-diy-led-control-with-ldr-sensor-photoresistor-fa011f

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
int photoSensorPin = A0;
int buttonPin = 2;
int ledPin1 = 9;
int ledPin2 = 10;
void setup() {
pinMode(photoSensorPin, INPUT);
pinMode(buttonPin, INPUT);
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
}
void loop() {
int sensorValue = analogRead(photoSensorPin);
int buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, HIGH);
} else if (sensorValue < 512) {
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, LOW);
} else {
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, LOW);
}
}
int photoSensorPin = A0; int buttonPin = 2; int ledPin1 = 9; int ledPin2 = 10; void setup() { pinMode(photoSensorPin, INPUT); pinMode(buttonPin, INPUT); pinMode(ledPin1, OUTPUT); pinMode(ledPin2, OUTPUT); } void loop() { int sensorValue = analogRead(photoSensorPin); int buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { digitalWrite(ledPin1, LOW); digitalWrite(ledPin2, HIGH); } else if (sensorValue < 512) { digitalWrite(ledPin1, HIGH); digitalWrite(ledPin2, LOW); } else { digitalWrite(ledPin1, LOW); digitalWrite(ledPin2, LOW); } }
int photoSensorPin = A0;
int buttonPin = 2;
int ledPin1 = 9;
int ledPin2 = 10;

void setup() {
  pinMode(photoSensorPin, INPUT);
  pinMode(buttonPin, INPUT);
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
}

void loop() {
  int sensorValue = analogRead(photoSensorPin);
  int buttonState = digitalRead(buttonPin);

  if (buttonState == HIGH) {
    digitalWrite(ledPin1, LOW);
    digitalWrite(ledPin2, HIGH);
  } else if (sensorValue < 512) {
    digitalWrite(ledPin1, HIGH);
    digitalWrite(ledPin2, LOW);
  } else {
    digitalWrite(ledPin1, LOW);
    digitalWrite(ledPin2, LOW);
  }
}

 

 

Beep Beep, Stuck in Traffic!

For this weeks assignment, I chose a very corny heading (sorry for that) but at the same time I combined some of the reading work we have previously done and implemented into the assignment.

My Inspiration came from the car industry, which is something I mentioned in one of my previous reading assignments. Since we are working with lights I thought that it would be a good idea to mimic some of the headlights that I’ve seen on never cars.

The way this lights work are:

  • When the driver turns to the left, the corresponding light turns on
  • When the driver turns to the right, the corresponding light turns on
  • The lights dim (in a way that if the turn is sharper, the light would be brighter)

To mimic this I used a potentiometer as well as two lights(logically :). For a fun element, I also added a buzzer and a button that activates that buzzer like a car horn would.

Here is the code I used:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
int potentiometer = A0;
const int led0 = 5;
const int led1 = 6;
const int buttonPin = 7;
int buttonRead = 0;
const int buzzerPin = 10;
void setup() {
Serial.begin(9600);
pinMode(led0, OUTPUT);
pinMode(led1, OUTPUT);
pinMode(buttonPin, INPUT);
pinMode(buzzerPin, OUTPUT);
}
void loop() {
buttonRead = digitalRead(buttonPin);
Serial.println(buttonRead);
int potentiometerValue = analogRead(potentiometer);
int pwmValue1 = map(potentiometerValue, 0, 512, 255, 0); // Map potentiometer value for LED0
int pwmValue2 = map(potentiometerValue, 513, 1023, 0, 255); // Map potentiometer value for LED1
// Check if the button is pressed (buttonRead is HIGH)
if (buttonRead == HIGH) {
// Turn on the buzzer
analogWrite(buzzerPin, HIGH);
} else {
// Turn off the buzzer
analogWrite(buzzerPin, LOW);
}
if (potentiometerValue >= 0 && potentiometerValue <= 512) {
analogWrite(led0, pwmValue1); // Dim LED0
analogWrite(led1, 0); // Turn off LED1
} else {
analogWrite(led0, 0); // Turn off LED0
analogWrite(led1, pwmValue2); // Dim LED1
}
}
int potentiometer = A0; const int led0 = 5; const int led1 = 6; const int buttonPin = 7; int buttonRead = 0; const int buzzerPin = 10; void setup() { Serial.begin(9600); pinMode(led0, OUTPUT); pinMode(led1, OUTPUT); pinMode(buttonPin, INPUT); pinMode(buzzerPin, OUTPUT); } void loop() { buttonRead = digitalRead(buttonPin); Serial.println(buttonRead); int potentiometerValue = analogRead(potentiometer); int pwmValue1 = map(potentiometerValue, 0, 512, 255, 0); // Map potentiometer value for LED0 int pwmValue2 = map(potentiometerValue, 513, 1023, 0, 255); // Map potentiometer value for LED1 // Check if the button is pressed (buttonRead is HIGH) if (buttonRead == HIGH) { // Turn on the buzzer analogWrite(buzzerPin, HIGH); } else { // Turn off the buzzer analogWrite(buzzerPin, LOW); } if (potentiometerValue >= 0 && potentiometerValue <= 512) { analogWrite(led0, pwmValue1); // Dim LED0 analogWrite(led1, 0); // Turn off LED1 } else { analogWrite(led0, 0); // Turn off LED0 analogWrite(led1, pwmValue2); // Dim LED1 } }
int potentiometer = A0;
const int led0 = 5;
const int led1 = 6;
const int buttonPin = 7;
int buttonRead = 0;
const int buzzerPin = 10;

void setup() {
  Serial.begin(9600);
  pinMode(led0, OUTPUT);
  pinMode(led1, OUTPUT);
  pinMode(buttonPin, INPUT);
  pinMode(buzzerPin, OUTPUT);
}

void loop() {
  buttonRead = digitalRead(buttonPin);
  Serial.println(buttonRead);
  int potentiometerValue = analogRead(potentiometer);
  int pwmValue1 = map(potentiometerValue, 0, 512, 255, 0); // Map potentiometer value for LED0
  int pwmValue2 = map(potentiometerValue, 513, 1023, 0, 255); // Map potentiometer value for LED1

  // Check if the button is pressed (buttonRead is HIGH)
  if (buttonRead == HIGH) {
    // Turn on the buzzer
    analogWrite(buzzerPin, HIGH);
  } else {
    // Turn off the buzzer
    analogWrite(buzzerPin, LOW);
  }

  if (potentiometerValue >= 0 && potentiometerValue <= 512) {
    analogWrite(led0, pwmValue1); // Dim LED0
    analogWrite(led1, 0); // Turn off LED1
  } else {
    analogWrite(led0, 0); // Turn off LED0
    analogWrite(led1, pwmValue2); // Dim LED1
  } 
}

Basically what the code does is it takes the potentiometer values, and maps them to the lights correspondigly. At the same time, the button turns the buzzer on and off.

Video demonstration:

 

Week 9 Assignment

For my project, I combined a light sensor and a button. The primary concept behind this project was to create an interactive system that responds to both room light levels and user input. The light sensor serves as the eyes of the circuit, detecting changes in the surrounding light environment, while the button enables direct user interaction. One of the main challenges I encountered during the development process was ensuring reliable and accurate responses with the light sensor, especially during the day when everything was lit up. I was thinking about some improvements for this project that could involve adding additional sensors for enhanced functionality, such as temperature or motion sensors, to broaden the range of environmental inputs the circuit can respond to. Overall, this project represents a stepping stone toward creating more sophisticated and responsive sensor-based systems for various applications. I would also work on my creativity in my next project since I was too focused on correcting this part.

Week 10 – Reading Response + Assignment_Shereena AlNuaimi

#1:
In 2008, TIGOE released a blog post titled “Physical Computing’s Greatest Hits (and misses),” which explores the field of physical computing by presenting a range of projects that illustrate the integration of technology with human interaction and creativity. It looks at how these initiatives, which include fun controllers like the “Stranglophone” and instruments resembling Theremins, blur the boundaries between engineering and art while highlighting the value of human interaction in technology.

The initiatives that are showcased strive to capture not only observable inputs but also intangible components of human experience, such emotional connection or inner quiet. They explore personal facets of everyday life, putting out gadgets that may be used in unusual ways, like screaming at people or giving them hugs.

In a sector full with repetitive concepts, the post critically examines what makes a work original and suggests that each creator’s little deviations are what make a work innovative. It supports the notion that, with gadgets acting as portals for inquiry and education, physical computing is about investigating human expression as much as it is about technology.

The post ends by extending an invitation to readers to take part in the development of physical computing and highlighting the necessity of ongoing innovation as well as the acceptance of change and adaptability in this ever-evolving industry. It provides room for development and fresh input, inspiring innovators, thinkers, and doers to push the envelope even farther.

#2:

The post “Making Interactive Art: Set the Stage, Then Shut Up and Listen” by TIGOE suggests changing the way interactive art is made. It promotes artists taking a backseat after establishing the scene so that viewers may participate and analyze the work on their own. Interactive art, in contrast to traditional art forms, starts a conversation that is co-authored by viewers. It is said that an artist should operate like a director would, offering suggestions but never forcing an interpretation on performers. The article emphasizes the artist’s humility in embracing a range of reactions from the audience, including misinterpretations or deceptions. It encourages artists to think of interactive pieces not as finished items but as continuous performances modified by audience involvement. Subsequently this implies that this method encourages participants’ emotional resonance and self-discovery. Ultimately, the post serves as a guide for creators navigating participatory culture, emphasizing the value of interactive art in sparking meaningful experiences.

 

ASSIGNMENT:

Bullseye Game!

Archery has been one of my passions for about 9 years now. I drew inspiration from the archery target by using the LED colors yellow, red and blue. When the button is pressed the yellow LED starts blinking and the blue and red LED turns off as if you hit a bullseye!

Week #10 – Reading Response

Among the first reading’s example, Fields of Grass attracted my curiosity the most. Thinking about it, I feel that the sensors could be organized in various ways so that the output changes dependent on not only the position of the hand, but also to the pressure applied. Designing a virtual world where the terrain alters depending on how firmly you push your hand is pretty cool. Delicate touches could disclose hidden passageways or generate peaceful sounds, while larger pressing might unleash bolder graphics or more dramatic effects. Beyond pressure, the sensor array might be adjusted to respond to additional hand interactions. An teaching tool might be created out of the project at a museum. Using pressure or movement to control elements like water or sunshine, visitors may “grow” a variety of virtual plants by placing their hands in specific locations. Physical therapy might benefit from the apps as well, as the virtual environment could react to particular hand gestures or muscle control, offering a visually appealing means of monitoring improvement.

In addition, I thought the author’s recommendation to “shut up and listen”—that is, to pay great attention to how people engage with and respond to the work—was extremely applicable to interface design in general, not just in artistic contexts. By seeing where our works fall short in the future, we may learn so much. Thus, it’s crucial to remain receptive to such criticism in order to improve the work. I also asked my friends to play games with me and give me constructive critique for my midterm.

 

Reading Reflection – Week 10

Among the various ideas explored in the blogs by Tom Igoe about physical computing, two projects particularly caught my attention: Floor Pads & Scooby-Doo Paintings. Using floor pads seems like a fun & creative way to create interactive experiences that suggest actions without telling users how to feel about those actions; it’s more like a performance, as described in the other reading. I’m curious to learn more about integrating floor pads into future projects, as well as gloves. The second concept, the Scooby-Doo paintings, reminded me of the Mona Lisa’s mysterious gaze, which some claim to be a myth. I wonder how much of a difference it makes to use a camera instead of a distance sensor to detect a face and eyes, and if anyone has attempted to recreate that with a reproduction of the Mona Lisa or another famous ancient painting.

Furthermore, the second essay about “Making Interactive Art” (enjoyed the catchy title) made several solid claims that I completely agree with. What makes art memorable is your experience with it, how it made you feel, which is unique to everyone…I appreciate the author’s emphasis on creating space for users to interpret things freely. Additionally, the idea of actively listening to audience responses & reactions reminded me of “user-testing.” So, I wonder if the author considers this before presenting the artwork and during as well. Is it about always leaving room for improvement and learning through the process? I never considered user-testing at any other stage besides before presenting, but consistently improving seems ideal. Overall, this encouraged me to experiment during the creative process and also while engaging with an audience because that’s when we learn most!

Week 9 – Sara Al Mehairi

CONCEPT

Ghost Detector Real Life Radar - Apps on Google PlayJahyShow 5 LED EMF Meter Magnetic Field Detector Ghost Hunting Paranormal Equipment Tester Counter - Walmart.com

Inspired by the LED EMF Meter Magnetic Field Detector (which helps to measure electromagnetic fields to identify equipment that generates high radiation) used for “ghost hunting,” my goal was to create a device similar to a “ghost detector.” Well, at least that’s the idea! Right now, it’s really good at detecting shadows, brightness, and darkness. Originally, I prototyped it as a device to light up cabinets, drawers, and more. But with some tinkering, it might just find something spooky—spirits! (p.s. this is for last week’s assignment)

OVERVIEW

The prototype is designed to detect changes in light levels using a photoresistor. It consists of a photoresistor connected to analog pin A0 on the Arduino board. The prototype includes four LEDs connected to digital pins 2, 3, 4, and 5, which illuminate in response to different brightness levels read by the photoresistor. Further, based on the brightness level detected, the Arduino activates specific combinations of LEDs to indicate the brightness level or as i would like to say “ghosts”

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
const int thresholds[] = {600, 500, 400, 300};
const int thresholds[] = {600, 500, 400, 300};
const int thresholds[] = {600, 500, 400, 300};
  1. If the brightness level exceeds the highest threshold, all four LEDs are illuminated, indicating maximum brightness.
  2. If the brightness level exceeds the second highest threshold, the first three LEDs are illuminated, while the fourth LED remains off.
  3. If the brightness level exceeds the third highest threshold, only the first two LEDs are illuminated, while the remaining LEDs are turned off.
  4. If the brightness level exceeds the lowest threshold, only the first LED is illuminated, while the remaining LEDs are turned off.
  5. If the brightness level falls below all thresholds, all LEDs are turned off.

IMPLEMENTATION

Prototype 1

As explained above, the photoresistor is able to detect the brightness level, to which range it belongs, and then the lights react accordingly. Do ghosts have shadows? Not necessarily… but anything is possible, so “use your imagination”. Perhaps it could even detect people or other moving objects.

Prototype 2

I know. We agreed not to use our hands, but no one mentioned anything about shadows. Here, I’m simply demonstrating the main concept of how it works. You could use your legs, face, or any other object. However, for the sake of a clear demonstration and a decent angle, I chose to use my hand’s shadow…not my hand.

Prototype 3

To further test its practicality, I decided to place it in my drawer. As you can see, it could prove quite useful with improved light adjustments.

CONCLUSION

It was certainly challenging to manage the numerous if-else cases and determine the appropriate ranges for the photoresistor. I invested a considerable amount of time debugging why certain LED lights functioned while others didn’t, only to realize that my else-if statements were not properly ordered, leading to skipped conditions. However, despite the constraint of not using our hands, I discovered a loophole, which allowed me to experiment with several of my ideas. (p.s. this is for last week’s assignment)