Week 9 Creative Switch – Khalifa Alshamsi

Concept:

In an endeavor to merge the timeless charm of LEGO with the dynamic glow of LED lighting, I took on a project that tested my creativity and also my persistence. The challenge was clear: integrate an LED system within a LEGO car in a functional and aesthetically pleasing manner. After numerous attempts and exploring various configurations, I found the perfect harmony by positioning the LED as the car’s internal dome light. This strategic placement allowed me to achieve an interactive feature where the light automatically turns on as the door closes and dims when the door is left open.

Code:

int ledPin = 9;           // LED connected to digital pin 9
int doorSensorPin = 2;    // Sensor (wires touching) connected to pin 2
int doorState = 0;        // Variable for reading the sensor status

void setup() {
  pinMode(ledPin, OUTPUT);      // Sets the digital pin as output
  pinMode(doorSensorPin, INPUT); // Sets the digital pin as input
  digitalWrite(doorSensorPin, LOW); // Enables pull-down resistor
}

void loop(){
  doorState = digitalRead(doorSensorPin); // Reads the state of the sensor value
  if (doorState == HIGH) {
     digitalWrite(ledPin, LOW);   // Turns LED off when the door is closed (wires touching)
  } else {
     digitalWrite(ledPin, HIGH);  // Turns LED on when the door is open (wires not touching)
  }
}

Video of Project:

Reflection and ideas for future work or improvements:

As I look back on this complicated project for me, I recognize the journey was as enlightening as it was challenging. One significant area for improvement that stands out is the need for a more refined wiring management system. Despite the project’s success, the sight of exposed wires and adhesive tape detracts from the overall aesthetic appeal. In future iterations, prioritizing a sleeker integration of the electronics will hopefully enhance the design.

Furthermore, this project served as a profound learning curve. Despite consuming countless videos and undergoing a trial-and-error process that saw me revising the wiring and code more times than I can count, I confess there remains a haze around my understanding of the underlying electronics principles. This realization, far from discouraging me, has sparked a curiosity to delve deeper into the fundamentals of electronics and programming.

Looking Ahead:

This project has laid the groundwork for further exploration into the fusion of technology with traditional toys. Ideas for future projects include incorporating more interactive elements, such as sound effects synchronized with the door’s motion or ambient light sensors to activate the headlights in dim conditions, transforming the LEGO car into an even more immersive and interactive experience, maybe even fully coding a 3D printed one to drive using the Arduino but again I still don’t know the full stretch of an Arduino board.

In essence, this journey has not only expanded my technical skills but also opened up a scenery of possibilities for exploring.

Week 9_Creative Switch – Jihad Jammal

Concept:

The requirement was clear: devise an alternative that bypasses the conventional hand-operated mechanism. Recognizing that our feet are just as capable when it comes to applying force in a precise manner—much like how we use them to operate pedals in a car—I decided to explore this avenue. I constructed a prototype using cardboard for the pedal, taking advantage of its availability and ease of manipulation, and copper for its conductive properties, essential for transferring the switch’s command.

A highlight of some code that you’re particularly proud of:

const int ledPin = 13; // LED connected to digital pin 13
const int touchSensorPin = 2; // Touch sensor (white wires) connected to digital pin 2

void setup() {
  pinMode(ledPin, OUTPUT); // Set the LED pin as output
  pinMode(touchSensorPin, INPUT_PULLUP); // Set the touch sensor pin as input with internal pull-up resistor
}

void loop() {
  // Check if touch sensor is touched (wires are connected)
  if (digitalRead(touchSensorPin) == LOW) {
    digitalWrite(ledPin, HIGH); // Turn on the LED
  } else {
    digitalWrite(ledPin, LOW); // Turn off the LED
  }
}

Video of Project:

Reflection and ideas for future work or improvements:

Reflecting on the process of creating my foot-operated light switch, I initially envisioned using aluminum for its excellent conductivity and lightweight properties. However, practical limitations often steer the course of innovation, and this project was no exception. With aluminum out of reach, I adapted to the materials available to me, selecting copper tape as a suitable alternative. This choice was not without its merits; copper’s conductivity is remarkable, and its flexibility proved invaluable during the assembly process.

The simplicity of the code was my saving grace, making the integration of electrical components less daunting than anticipated. Yet, every project presents its challenges. One such challenge was securing the wires in such a manner that they consistently made contact with the copper tape. Due to their placement, there were occasions when the connection was missed, disrupting the switch’s functionality. I recognized that increasing the copper tape’s surface area could potentially mitigate this issue, providing a more forgiving target for the wires to connect with.

 

Week 9: Unusual Switch

Overview

In this assignment, I was tasked with designing a unique switch that doesn’t use hands for activation. I embraced the challenge with creativity, creating two distinct switches: a water detection switch and a bicep flexion switch.

Switch 1: Water Detection System with Visual Indicator

Concept

The concept behind this water detection system is rooted in the fundamental principle of electrical conductivity in water. Utilizing a simple circuit design with an Arduino, the project aims to detect the presence or absence of water through basic electronic components. When water connects two strategically placed wires, it completes a circuit, allowing current to flow, which the Arduino interprets to trigger a visual signal.

Inspiration

The inspiration for this project came from the need to monitor water levels or detect water presence in various situations, such as checking if a plant needs watering or preventing overflow in tanks.

Image

Components Used

  1.  Arduino Uno
  2. Green LED
  3. Red LED
  4. 330Ω Resistors (2)
  5. Jumper Wires
  6. Breadboard

How It Works

  • I connected the anode of each LED (green and red) through a 330Ω resistor to digital pins 13 and 12 on the Arduino, respectively. The cathodes were connected to the ground (GND).
  • I prepared two wires as water sensors by stripping a small section of insulation off each end. One wire was connected to digital pin 2 on the Arduino, and the other wire was connected to GND. These wires were then placed close to each other but not touching, ready to be submerged in water.
  • I wrote and uploaded the code to the Arduino that checks the electrical connection between the sensor wires. If water is present (completing the circuit), the green LED turns on. If the circuit is open (no water detected), the red LED illuminates.

Video

Switch 2: Bicep Switch

Concept

The goal was to create a device that could detect muscle flexion, particularly of the bicep, and provide immediate visual feedback.

The circuit setup and the code used are the same as the water detection switch.

Image

Components Used

  1.  Arduino Uno
  2. Green LED
  3. Red LED
  4. 330Ω Resistors (2)
  5. Jumper Wires
  6. Breadboard
  7. Cardboard Pieces
  8. Copper Tape

How It Works

When the bicep is flexed, the circuit completes, and the green LED lights up, indicating muscle activity. Conversely, when the muscle relaxes, the circuit breaks and the red LED turns on, indicating that the muscle is at rest.

Video

Week 9: Creative Switch

For this assignment, I made a water-based switch. Thinking of a switch that does not use your hands is really tricky so I started thinking of conductors that could be easily placed and removed with a part of the human body that isn’t the hands. My mind immediately went to water – or well, technically, spit (essentially using your mouth to connect the circuit with water as a conductor).

Implementation

My circuit is based on the circuit we built in class with a switch whose state controls the action of an LED light. The Arduino code is simple, reading the state of the water switch and illuminating the LED if water is detected.

const int waterSwitchPin = 2;  // water switch digital pin 
const int ledPin = 13;         // LED digital pin 

void setup() {
  pinMode(waterSwitchPin, INPUT); // set water switch pin as input
  pinMode(ledPin, OUTPUT);        // set LED pin as output
  Serial.begin(9600);
}

void loop() {
  int waterSwitchPinState = digitalRead(waterSwitchPin); // read the state of water switch
  Serial.println(waterSwitchPinState);
  if (waterSwitchPinState == HIGH) { // water detected
    digitalWrite(ledPin, HIGH); // turn on LED
  } else { // no water detected
    digitalWrite(ledPin, LOW); // turn off LED
  }
  
}

To make the switch, I place two jumper wires in an empty bottle cap such that they are separated. I initially thought of just spitting water into the cap to create conductivity between the wires and turn the switch state to HIGH. However, Darko (thank you, Darko) rightfully pointed out that a true switch should also be switched off and suggested the use of a straw to lower the level of water in the cap and break the circuit. It was difficult to make sure the straw remained stable without using my hands but I managed to pull it off. I also had to use salt to make sure the water was ionized enough to conduct (thank you, Professor Aaron, for the trick!).

 

 

 

Afra Binjerais – Week 9 assignment

Unusual Switch – Drink Me

For this assignment, I really struggled being creative, maybe because I’m fasting 🙂

I explored various metals in my room to discover a novel method for illuminating an LED. Eventually, I decided to use a metal straw as the conductor between two wires. By placing it in a cup and using my mouth to press the straw onto the wires, the LED lights up.

This is what my Arduino looked like:

Those two white wires were taped on the table, very close to each other but not touching.

I covered it with a cup to create the effect of drinking.

My niece volunteered to demonstrate this project. This is the LINK to the video

Lastly, this is my code:

const int ledPin = 2;      // Use pin 2 to control the LED
const int touchPin = 7;    // Use pin 7 to read the touch state

void setup() {
  pinMode(ledPin, OUTPUT);    // Initialize the LED pin as an output
  pinMode(touchPin, INPUT_PULLUP); // Initialize the touch pin as an input with internal pull-up resistor
}

void loop() {
  int touchState = digitalRead(touchPin); // Read the state of the touch pin
  
  if (touchState == LOW) {   // If wire A touches the wire on line 5, it will be LOW
    digitalWrite(ledPin, HIGH); // Turn on the LED
  } else {
    digitalWrite(ledPin, LOW);  // Turn off the LED
  }
}

I really enjoyed making this switch, and seeing it work at the end was truly rewarding.

Pi : Fwitch – A Flute Controlled Steampunk Switch

Guitar is overrated 🎸😒. Anyone who got impressed by a electric guitar controlled cyberpunk game should seriously raise their standards.

When I am not working on brain controlled robots, I look after my child, called The Tale of Lin & Lang,  which is a fictional universe where Industrial Revolution began in East Asia (China/Korea/Japan), and a re-imagination of alternative history. In that world, there are steampunk inventors who invent computers, clockwork, machines … and there are also artisans who plays the traditional bamboo flute (笛子 – dízi).

Well, that’s fiction…. or is it 🤔? Well, in real life, I am also a bamboo flute player and an inventor, and a steampunk enthusiast…. so I present Fwitch, a flute controlled steampunk switch.

Below is the complete demonstration.

HOW IT WORKS

It’s a switch, so nothing complicated. One end of the wire needs to go and meet another wire… I am just driving the motion using 2 steampunk style gears I 3D printed and painted.

When I blow the flute, the laptop mic listens to my flute volume, and above a particular threshold, will establish a serial connection to arduino and tell the servo motor to rotate to a particular degree. And with another note from the flute, it will toggle the switch. Simple.

The servo I am using is quite large (because the gears are large), hence I need an external power supply. It is hidden in the container below to be neat and tidy.

And yes, I am using a Chinese clone mega board.

Below are close up shots.

CODE

The following python code listens to the microphone on my computer, and above a particular volume threshold, it will send switch on and off signal through serial to arduino. I could have used a mic and do everything on arduino, but could not find one, so decided to use my laptop mic.

import pyaudio
import numpy as np
import os
import time
import serial
import serial.tools.list_ports

switch_on = False
volume_threshold = 30  # Configurable threshold
switch_toggled = False  # Flag to track if the switch was toggled

def clear_screen():
    # Clear the console screen.
    os.system('cls' if os.name == 'nt' else 'clear')

def list_serial_ports():
    ports = serial.tools.list_ports.comports()
    return ports

def get_volume(data, frame_count, time_info, status):
    global switch_on, switch_toggled

    audio_data = np.frombuffer(data, dtype=np.int16)
    if len(audio_data) > 0:
        volume = np.mean(np.abs(audio_data))
        num_stars = max(1, int(volume / 100))

        if num_stars > volume_threshold and not switch_toggled:
            switch_on = not switch_on
            ser.write(b'180\n' if switch_on else b'0\n')
            switch_toggled = True
        elif num_stars <= volume_threshold and switch_toggled:
            switch_toggled = False

        clear_screen()
        print(f"Switch:{switch_on}\nVolume: {'*' * num_stars}")

    return None, pyaudio.paContinue

# List and select serial port
ports = list_serial_ports()
for i, port in enumerate(ports):
    print(f"{i}: {port}")
selected_port = int(input("Select port number: "))
ser = serial.Serial(ports[selected_port].device, 9600)
time.sleep(2)  # Wait for serial connection to initialize
ser.write(b'0\n')  # Initialize with switch off

# Audio setup
FORMAT = pyaudio.paInt16
CHANNELS = 1
RATE = 44100
CHUNK = 1024

audio = pyaudio.PyAudio()

# Start the stream to record audio
stream = audio.open(format=FORMAT, channels=CHANNELS,
                    rate=RATE, input=True,
                    frames_per_buffer=CHUNK,
                    stream_callback=get_volume)

# Start the stream
stream.start_stream()

# Keep the script running until you stop it
try:
    while True:
        time.sleep(0.1)
except KeyboardInterrupt:
    # Stop and close the stream and serial
    stream.stop_stream()
    stream.close()
    ser.close()
    audio.terminate()

And this arduino part listens to the serial from python, and rotates the servo accordingly.

#include <Servo.h>

Servo myservo;  
int val;        

void setup() {
  myservo.attach(9); 
  Serial.begin(9600);
  Serial.println("Servo Controller Ready");
}

void loop() {
  if (Serial.available() > 0) {
    String input = Serial.readStringUntil('\n'); // read the string until newline
    val = input.toInt(); // convert the string to integer

    val = constrain(val, 0, 180);

    myservo.write(val);      
    Serial.print("Position set to: ");
    Serial.println(val);     
    delay(15);               
  }
}

Hope you enjoy.

Remarks

Well, since the assignment rubric required use of Arduino, I am using the Arduino. Had it been the original assignment without Arduino, things could have gotten more interesting 🤔. Arduino is a tool, transistors are tools. Many people are so inclined to believe that in order to implement a programmable logic, we need electronics.

🚫 NOOOO!!!!

My inner computer engineer says logic can be implemented anywhere with proper mechanism, and if you can implement logic, anything is a computer.

  • 🧬 Human DNA is just a program to read lines of nucleobases and produce proteins based on that.
  • 💧We can use water and pipes to implement logic gates and design our hydro switch.
  • 🍳If I wanted to, even the omelette on my breakfast plate can be a switch.

We don’t even need 3 pin transistors , we can design purely “Mechanical” logic gates and design the switch. But oh well… putting back my celestial mechanics into my pocket.

Week 9 – Unusual Switch

Ever since professor Sherwood told us about this assignment, I have started to think about how can I use my feet in order to make the LED light go on.

At first, I discovered that I need to use a sensor, which I found in the kit. Then, with a little inspiration from one of my favorite bands ever, Queen, I started to think about interactive ways to make this happen.

This was the result (excuse my PJs and slippers I was sick) :

At first, my right leg is right in front of the sensor. After the first few kicks, I move the right leg right next to the sensor, so that the LED light will turn off.

This was the code that I used:

//declaring the pins of the sensors
const int trigPin = 12;
const int echoPin = 13;
long duration; 
int distance;

//declaring the rgb led
int rgb_r = 8;
int rgb_b = 7;
int rgb_g = 4;

void setup() {
  // put your setup code here, to run once:
  pinMode(echoPin, INPUT);
  pinMode(trigPin, OUTPUT);
  pinMode(rgb_r, OUTPUT);
  pinMode(rgb_b, OUTPUT);
  pinMode(rgb_g, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);

  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  duration = pulseIn(echoPin, HIGH);
  distance = duration * 0.034 / 2;

  // We check the measured distance and control the RGB LED depending on it
  // If distance between 20-50 cm, LED is blue
    analogWrite(rgb_r, 0);
    analogWrite(rgb_g, 0);
    analogWrite(rgb_b, 255);
    Serial.println("Led is blue!");

  }

  delay(1000);
  Serial.print("distance = ");
  Serial.print(distance);
  Serial.print("\n");
  delay(1000);
}

It would have been complete if I added the hand claps with the kicks for sound purposes but I did not want to be taxed for that in regards to my grade 🙂 .

Overall, it was fun to make. The sensor is not that strong so in the future I would like to use something stronger maybe. Also, this can become an actual project and I could make it so that the color of the led would change when your feet have different positions.

Luke Nguyen – Week 9 Assignment – Lantern

 

 

Concept & Inspiration:

It’s during Ramadan and I wanted to capture the spirit and create something inspired by the month. I was working in the majlis room available in the Baraha area in C2 and I found this lamp stashed in the room corner. When I picked it up and opened the door, I noticed there was no light inside. It gave me the idea of putting a light in there with this assignment.

Circuit:

 

Demo:

Since the requirement of the assignment is creating an unusual switch that uses no hand, I thought of the idea that when the door is closed, the light will turn on. The body of the lamp besides the glass is made of metal material so it should transmit electricity almost everywhere on the surface. Taking advantage of this, I rigged the circuit inside the lamp and arranged of the placement of 2 jumper wires so that when the lamp’s door is closed, the circuit is closed and the LED will turn on thanks to the current running through it.

I created the entire circuit outside of the lamp, estimated the number of jumper wires I would need, then rigged/taped the circuit inside later though.

Challenges and reflections:

Initially, I planned to attach the 2 jumper wires in a way that when the door is closed, they would close the circuit. But that was not possible all the time because of the tape. So I took advantage of the material which the surface of the lamp is made of instead. The point is as long as their is a current running through the LED. Other than that, taping the entire circuit inside the lamp took a little bit of time because the space was too small for my hands, but I managed to do it.

Extremely weird kissing switch!

My main motivation came from Professor Aaron. Professor wanted us to be weird so I decided to be as weird as I can and decided to make a kissing switch 🙂

It started of with the ideation where I took inspiration from one of the videos we were shown in class where a guys connected cables with aluminum foil to his face and his face moved with the sound. That way I decided that one part would be attached to the face and one part would be placed on a cardboard pad.

With some sketchy soldering I soldered the Arduino cables to longer ones so that the kissing pad can be more accessible from a distance:

Here is how the kissing pad looks like:

Finally when everything was connected, I wanted the lights to blink in the tempo of a heartbeat when a kiss occurs. So naturally I searched up on Google what is the heartbeat of a person that is kissing. The answer was: 100. Let’s implement that into our code:

void heartbeatLED() {
  // Calculate the duration of one beat in milliseconds
  int beatDuration = 60000 / 100; // 100 beats per minute

  // Half of the beat duration for on and off phases
  int phaseDuration = beatDuration / 2;

  // Blink the LED with heartbeat rhythm
  for (int i = 0; i < 100; i++) { // Blink for 100 heartbeats
    digitalWrite(led0, HIGH); // Turn the LED on
    delay(phaseDuration); // Wait for the on phase
    digitalWrite(led0, LOW); // Turn the LED off
    delay(phaseDuration); // Wait for the off phase
  }
}

Finally, this is how everything looks connected together (practical presentation of how it works will be shown in class):

Video Demonstration:

I also arranged the lights in a heart formation whilst still thinking of how to make a “casing” in heart shape to make it look more pretty.

Overall I really liked exploring the Arduino for the first time and really tried to make something weird and push myself out of my comfort zone. I’m really excited for what is about to come 🙂

Week 8 Response

While reading the articles, it was challenging to find a link between the ideas due to the different design contexts discussed: Norman’s focus on emotional interaction with design and objects, versus McMillan’s article on Margaret Hamilton’s significant contributions to the Apollo mission. However, both narratives highlight the importance of innovative thinking and emotional engagement in creating technologies that are not only functional but also meaningful and intuitive for users. Adding to this, the concept discussed earlier in the semester, that design should be self-explanatory, resonates here. For example, Norman might argue that a well-designed object or interface naturally guides the user on how to interact with it, reducing the need for extensive instructions or training. Hamilton’s software, by being robust and error-tolerant, exemplifies this principle on a technical scale, ensuring astronauts could rely on it under the most extreme conditions without needing to understand its complexities.