Week 11 Project Exercises

 

 

 

Exercise 1.1

let port;
let connectBtn;
let baudrate = 9600;
let lastMessage = "";

function setup() {
  createCanvas(400, 400);
  background(220);

  port = createSerial();

  // in setup, we can open ports we have used previously
  // without user interaction

  let usedPorts = usedSerialPorts();
  if (usedPorts.length > 0) {
    port.open(usedPorts[0], baudrate);
  }

  // any other ports can be opened via a dialog after
  // user interaction (see connectBtnClick below)

  connectBtn = createButton("Connect to Arduino");
  connectBtn.position(80, 200);
  connectBtn.mousePressed(connectBtnClick);

}

function draw() {
  background("255");
  

  
  // Read from the serial port. This non-blocking function
  // returns the complete line until the character or ""
  let str = port.readUntil("\n");
  if (str.length > 0) {
    // Complete line received
    // console.log(str);
    lastMessage = str;
    
  
  }
  
      
  
  // Display the most recent message
  text("Last message: " + lastMessage, 10, height - 20);

  // change button label based on connection status
  if (!port.opened()) {
    connectBtn.html("Connect to Arduino");
  } else {
    connectBtn.html("Disconnect");
  }
  
  
  ellipse(lastMessage,10,20,20)
}

function connectBtnClick() {
  if (!port.opened()) {
    port.open("Arduino", baudrate);
  } else {
    port.close();
  }
}

 

Exercise 1.2

let port;
let connectBtn;
let baudrate = 9600;
function setup() {
  createCanvas(255, 285);
  port = createSerial();
  let usedPorts = usedSerialPorts();
  if (usedPorts.length > 0) {
  port.open(usedPorts[0], baudrate);
 } else {
  connectBtn = createButton("Connect to Serial");
  connectBtn.mousePressed(() => port.open(baudrate));
 }
}
function draw() {
  background(225);
  circle(140,mouseY,25,25):
  let sendtoArduino = String(mouseY) + "\n"
  port.write(sendtoArduino);
}

Exercise 1.3

 

 

int led = 5;
void setup() {
  Serial.begin(9600);
}
 
void loop() {
  if (Serial.available()) {
    int ballState = Serial.parseInt(); 
    if (ballState == 1) {
      digitalWrite(led, HIGH); // ball on ground
    } else {
      digitalWrite(led, LOW); // ball in air or default
     }
  }
  // read the input pin:
  int potentiometer = analogRead(A1);                  
  int mappedPotValue = map(potentiometer, 0, 1023, 0, 900); 
  // print the value to the serial port.
  Serial.println(mappedPotValue);                                            
  
  delay(100);
}

 

 

 

 

Reading Response: Design Meets Disability

The text prompted me to reflect deeply on the role of design in shaping not only products but also perceptions and identities- especially for those of us working in product design. The text challenges the traditional boundaries between medical necessity and mainstream desirability, and as a designer, I find both inspiration and discomfort in this tension.

One point that stands out is the way the Eameses’ leg splint for the U.S. Navy, originally a response to a medical brief, became a catalyst for innovations that transformed mainstream furniture design. The author’s admiration for the leg splint’s “organic form and geometric holes, the combination of subtle surfaces and crisp edges” resonates with me because it exemplifies how constraints can drive creativity. The evidence is clear: the technology and aesthetic language developed for a medical device directly influenced the iconic Eames furniture. This makes me think about how often, in design for disability, we excuse poor design because of the market or the context, rather than holding it to the same standards as mainstream products. It prompts me to question: why shouldn’t design for disability be as beautiful, as considered, and as desirable as anything else?

However, I am uneasy about the persistent bias towards discretion in assistive products. The text critiques the tradition of camouflaging medical devices- pink plastic hearing aids, for instance- in an attempt to make them invisible. The author argues that this approach can inadvertently reinforce the idea that disability is something to be hidden, rather than embraced. The evidence comes from the evolution of eyewear: glasses have transitioned from stigmatized medical appliances to fashion statements, even to the point where people without visual impairments wear them as accessories. This shift did not come from making glasses invisible, but from making them objects of desire. It makes me realise that, as a designer, I should challenge the default of discretion and instead explore how products can project positive identities.

The discussion of fashion’s role in design for disability is particularly provocative. The text points out that fashion and discretion are not true opposites, but there is a creative tension between them. Fashion’s embrace of diversity and its ability to make wearers feel good about themselves stands in stark contrast to the clinical, problem-solving culture that dominates medical design. The evidence is in the HearWear project, where inviting designers from outside the medical field led to radical new concepts for hearing aids- some playful, some overtly technological, and some drawing on jewellery and body adornment. This makes me reflect on my own practice: am I too quick to prioritise technical performance and problem-solving at the expense of self-expression and emotional value?

What I particularly like about the text is its insistence on keeping “the design in design for disability.” The author links the success of products like the iPod to a relentless focus on simplicity and attention to detail, arguing that these same sensibilities are often missing from assistive products because designers are not involved early enough in the process. The point is well made: design is not just about how something looks, but how it works and how it makes people feel. The evidence is in the contrast between the iPod’s iconic simplicity and the “flying submarine” syndrome of overburdened, over-complicated universal designs that try to be everything to everyone and end up pleasing no one. This reminds me that good design often means having the courage to say no to unnecessary features, and instead focusing on the essence of the product and the experience it creates.

Yet, I dislike the way the field of design for disability is still so often siloed and marginalised, both in practice and in perception. The text highlights how multidisciplinary teams developing prosthetics rarely include industrial or fashion designers, let alone sculptors or artists. The result is products that may function well but fail to resonate emotionally or culturally with their users. The evidence comes from the stories of Aimee Mullins and Hugh Herr, who both see their prostheses not just as tools but as extensions of their identity- sometimes even as sources of pride or advantage. This makes me think about the importance of diversity, not only among users but also among designers. We need to bring in more voices, more perspectives, and more creativity if we are to create products that are truly inclusive and empowering.

In conclusion, this text has challenged me to rethink my approach as a designer. It has made me more aware of the cultural and emotional dimensions of product design, especially in the context of disability. I am inspired to seek a healthier balance between problem-solving and playful exploration, between discretion and fashion, and between universality and simplicity. Most of all, I am reminded that design has the power to shape not only products but also identities and societies- and that this responsibility should never be taken lightly.

Preliminary Concept: Multiplayer Character Card Game System Using Arduino and p5.js

Finalised Concept

For my final project, I am designing an interactive multiplayer game system inspired by the iconic Yu-Gi-Oh! duel disk, but reimagined for creative, social play. Players use physical cards embedded with unique identifiers (such as RFID or NFC tags) to represent custom characters they create. These cards are scanned by an Arduino-powered duel disk, allowing each player to join the game with their personalized avatar and stats. The system supports multiple players competing in a series of mini-games or trivia challenges, with all real-time visuals and game logic handled by a p5.js interface on the computer.

This project merges tangible interaction (physical cards and duel disk) with digital feedback (customizable avatars, live scores, and dynamic mini-games), creating a seamless, engaging experience that emphasizes both individual expression and social play.

Arduino Program Design

Inputs:

  • Multiple RFID/NFC readers (or a shared reader for sequential scans), each detecting when a player places their card on the duel disk.

  • Optional: Buttons or touch sensors for additional in-game actions.

Outputs:

  • LEDs, buzzers, or vibration motors embedded in the disk to provide physical feedback (e.g., indicate successful scans, turns, or game outcomes).

Communication:

  • When a card is scanned, Arduino reads the card’s unique ID and sends it to the computer via serial communication.

  • Arduino can also receive commands from p5.js (e.g., to trigger LEDs or buzzers when a player wins a round).

Summary of Arduino’s Role:

  • Listen for card scans and input actions.

  • Transmit card IDs and sensor data to p5.js promptly.

  • Receive feedback commands from p5.js to control physical outputs.

p5.js Program Design

Responsibilities:

  • Listen for incoming serial data from the Arduino (card IDs, button presses).

  • Match each card ID to a player profile, loading their custom character (name, avatar, stats).

  • Allow players to customize their characters through a user-friendly interface.

  • Manage the game flow: let multiple players join, select mini-games, and track scores.

  • Display real-time game visuals, avatars, and results.

  • Send commands back to Arduino to trigger physical feedback (e.g., light up the winning player’s section).

Data Flow:

  • On card scan: p5.js receives the ID, loads or prompts for player customization, and adds the player to the game.

  • During play: p5.js updates visuals and scores based on game logic and player actions.

  • On game events: p5.js sends output commands to Arduino for physical feedback.

Interaction Design

  • Joining the Game: Each player places their card on the duel disk. The Arduino detects the card, and p5.js loads their profile or prompts for customization.

  • Customizing Characters: Players can use the p5.js interface to personalize their avatars, choose stats, and save progress.

  • Starting a Game: Once all players have joined, they select a mini-game or trivia challenge.

  • Gameplay: Players compete head-to-head or in teams, with p5.js managing the game logic and displaying results. Physical feedback (lights, sounds) enhances the experience.

  • Winning and Progression: Scores and achievements are tracked per player, and leaderboards are displayed at the end of each round.

System Communication

  • Arduino → p5.js: Sends card IDs and sensor/button states.

  • p5.js → Arduino: Sends commands to trigger LEDs, buzzers, or other outputs based on in-game events.

Project Progress and Next Steps

  • Prototyping: I am currently prototyping the card scanning system with Arduino and testing serial communication with p5.js.

  • UI/UX: Early sketches for the p5.js interface focus on clear avatar displays, easy customization, and intuitive game flow.

  • Game Logic: I am developing the first mini-game (a trivia challenge) and designing the multiplayer logic to support dynamic player counts.

Why This Project?

This system blends physical and digital interaction in a way that is social, customizable, and fun. It encourages users to invest in their characters and compete or collaborate with others, making every session unique. The project leverages Arduino for timely, tangible sensing and feedback, while p5.js handles multimedia processing and engaging visual responses- fulfilling the assignment’s requirements for a responsive, multimedia interactive system.

Week 11 – Assignment

Task 1:

We made it so that the program shows a circle on the screen that moves left and right when u rotate the potentiometer. The Arduino sends values to p5, and p5 reads those values through the serial port. As the potentiometer is rotated, the circle moves across the canvas to match its position. Theres also a button in the sketch that lets you connect to the Arduino manually.

p5.js

let serialPort;         // connection to the arduino
let connectButton;      // button to connect to arduino
let serialSpeed = 9600; // speed of communication between p5 and arduino
let xCircle = 300;      // starting x position of circle

function setup() {
  createCanvas(300, 300);
  background(245);

  serialPort = createSerial();

  let previous = usedSerialPorts();
  if (previous.length > 0) {
    serialPort.open(previous[0], serialSpeed);
  }

  connectButton = createButton("Connect Arduino"); // connect button
  connectButton.mousePressed(() => serialPort.open(serialSpeed)); // when clicked, connect
}

function draw() {
  let data = serialPort.readUntil("\n");  // reads the data from arduino

  if (data.length > 0) {       // if data received
    let sensorValue = int(data); // convert it to a number
    xCircle = sensorValue;       // use it to update the circles x position
  }

  background(245);
  fill(255, 80, 100);
  noStroke();
  ellipse(xCircle, height/2, 35); // draw circle at new position
}

Arduino

void setup() {
  Serial.begin(9600); // initialize serial communications
}
 
void loop() {
  // read the input pin:
  int potentiometer = analogRead(A1);                  
  // remap the pot value to 0-300:
  int mappedPotValue = map(potentiometer, 0, 1023, 0, 300); 
  Serial.println(mappedPotValue);
  // slight delay to stabilize the ADC:
  delay(1);                                            
  delay(100);
}

Task 2:

When the Arduino receives the letter ‘H’, it turns the LED on. When it receives the letter ‘L’, it turns the LED off. This lets you control the LED p5 by pressing the “Turn ON” or “Turn OFF” buttons.

p5.js

let serialPort;
let connectButton;
let serialSpeed = 9600;

function setup() {
  createCanvas(300, 200);
  background(240);

  serialPort = createSerial(); // create serial port connection

  let prev = usedSerialPorts(); // check if theres a previously used port
  if (prev.length > 0) {
    serialPort.open(prev[0], serialSpeed);
  }

  connectButton = createButton("Connect Arduino");
  connectButton.position(10, 10); // button position
  connectButton.mousePressed(() => serialPort.open(serialSpeed)); // open port when button clicked

  let onBtn = createButton("Turn ON"); // button to turn the LED on
  onBtn.position(10, 50); // position of ON button
  onBtn.mousePressed(() => serialPort.write('H')); // Send 'H' to arduino when pressed

  let offBtn = createButton("Turn OFF"); // button to turn the LED off
  offBtn.position(90, 50); // position of OFF button
  offBtn.mousePressed(() => serialPort.write('L')); // send 'L' to arduino when pressed
}

function draw() {
}

Arduino

void setup() {
  pinMode(9, OUTPUT);        // LED on pin 9
  Serial.begin(9600);        // start serial communication
}

void loop() {
  if (Serial.available()) {
    char c = Serial.read();

    if (c == 'H') {
      digitalWrite(9, HIGH); // turn LED on
    }
    else if (c == 'L') {
      digitalWrite(9, LOW);  // turn LED off
    }
  }
}

Task 3:

We used serialPort to read the sensor value and mapped it to wind force. To light up the LED only once per bounce, we added a boolean flag (ledTriggered). When the ball hits the ground, it sends a signal like ‘H’ to the Arduino to turn on the LED and ‘L’ to turn it off.

p5.js

let velocity;
let gravity;
let position;
let acceleration;
let wind;
let drag = 0.99;
let mass = 50;
let serial;
let connectBtn;
let ledTriggered = false;

function setup() {
  createCanvas(640, 360);
  noFill();
  position = createVector(width / 2, 0);
  velocity = createVector(0, 0);
  acceleration = createVector(0, 0);
  gravity = createVector(0, 0.5 * mass);
  wind = createVector(0, 0);

  // setup serial connection
  serial = createSerial();
  let previous = usedSerialPorts();
  if (previous.length > 0) {
    serial.open(previous[0], 9600);
  }

  connectBtn = createButton("Connect to Arduino");
  connectBtn.position(10, height + 10); // button position
  connectBtn.mousePressed(() => serial.open(9600));
}

function draw() {
  background(255);
  // check if we received any data
  let sensorData = serial.readUntil("\n");

  if (sensorData.length > 0) {
  // convert string to an integer after trimming spaces or newline

    let analogVal = int(sensorData.trim());
    let windForce = map(analogVal, 0, 1023, -1, 1);
    wind.x = windForce; // horizontal wind force
  }

  applyForce(wind);
  applyForce(gravity);
  velocity.add(acceleration);
  velocity.mult(drag);
  position.add(velocity);
  acceleration.mult(0);
  ellipse(position.x, position.y, mass, mass);
  if (position.y > height - mass / 2) {
    velocity.y *= -0.9; // A little dampening when hitting the bottom
    position.y = height - mass / 2;

    if (!ledTriggered) {
      serial.write("1\n");   // trigger arduino LED
      ledTriggered = true;
    }
  } else {
    ledTriggered = false;
  }
}

function applyForce(force) {
  // Newton's 2nd law: F = M * A
  // or A = F / M
  let f = p5.Vector.div(force, mass);
  acceleration.add(f);
}

function keyPressed() {
  if (key === ' ') {
    mass = random(15, 80);
    position.y = -mass;
    velocity.mult(0);
  }
}

Arduino

int ledPin = 5;

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

void loop() {
  // send sensor value to p5.js
  int sensor = analogRead(A1);
  Serial.println(sensor);
  delay(100);

  // check for '1' from p5 to trigger LED
  if (Serial.available()) {
    char c = Serial.read();
    if (c == '1') {
      digitalWrite(ledPin, HIGH);
      delay(100);
      digitalWrite(ledPin, LOW);
    }
  }
}

Assignment 10: Make a musical instrument

This is my Melodic Button Machine. It uses three push buttons (digital sensors) and a potentiometer (analog sensor) to create a simple, playful musical instrument. Each button plays a different musical note, while the potentiometer allows the player to bend the pitch of the note in real time- much like a musician bending a guitar string or sliding a trombone.

Machine Shown in Class

Assignment Brief

The assignment challenged us to create a musical instrument using Arduino technology. The requirements were clear: incorporate at least one digital sensor (such as a switch or button) and at least one analog sensor (like a potentiometer, photoresistor, or distance sensor). The instrument should respond to user input in a way that is both interactive and expressive.

Conceptualisation

The idea for this project emerged from my fascination with the simplicity of early electronic instruments. I remembered a childhood toy keyboard that could produce a handful of notes, and how magical it felt to create music with just a few buttons. I wanted to recreate that sense of wonder, but with a modern DIY twist. I also wanted to explore how analog and digital sensors could work together to give the user expressive control over the sound.

Process

Component Selection: I started by gathering the essential components: an Arduino Uno, a breadboard, three push buttons, a potentiometer, a piezo buzzer, jumper wires, and a handful of resistors. The buttons would serve as the digital inputs for note selection, while the potentiometer would act as the analog input to modulate pitch.

Circuit Assembly: The buttons were wired to digital pins 2, 3, and 4 on the Arduino, with internal pull-up resistors enabled in the code. The potentiometer’s middle pin was connected to analog pin A0, with its outer pins going to 5V and GND. The piezo buzzer was connected to digital pin 8, ready to bring the project to life with sound.

Code Development: I wrote Arduino code that assigned each button a specific musical note: C, D, or E. The potentiometer’s value was mapped to a pitch modulation range, so turning it would raise or lower the note’s frequency. This allowed for playful experimentation and made the effect of the potentiometer obvious and satisfying. I tested the code, tweaking the modulation range to make sure the pitch bend was dramatic and easy to hear.

Testing and Tuning: Once everything was wired up, I played simple tunes like “Mary Had a Little Lamb” and “Hot Cross Buns” by pressing the buttons in sequence. The potentiometer added a fun twist, letting me add vibrato or slides to each note.

Challenges

Pitch Range Calibration:
Finding the right modulation range for the potentiometer was tricky. If the range was too wide, the notes sounded unnatural; too narrow, and the effect was barely noticeable. After some trial and error, I settled on a ±100 Hz range for a musical yet expressive pitch bend.

Wiring Confusion:
With multiple buttons and sensors, it was easy to mix up wires on the breadboard. I solved this by colour-coding my jumper wires and double-checking each connection before powering up.

Potential Improvements

More Notes:
Adding more buttons would allow for a wider range of songs and melodies. With just three notes, the instrument can play simple tunes, but five or more would open up new musical possibilities.

Polyphony:
Currently, only one note can be played at a time. With some code modifications and additional hardware, I could allow for chords or overlapping notes.

Alternative Sensors:
Swapping the potentiometer for a light sensor or distance sensor could make the instrument even more interactive.

Visual Feedback:
Adding LEDs that light up with each button press or change colour with the pitch would make the instrument more visually engaging.

Schematics

Source Code

const int button1Pin = 2;
const int button2Pin = 3;
const int button3Pin = 4;
const int potPin = A0;
const int buzzerPin = 8;

// Define base frequencies for three notes (C4, E4, G4)
const int noteC = 262;  // C4
const int noteE = 330;  // E4
const int noteG = 294;  // D4

void setup() {
  pinMode(button1Pin, INPUT_PULLUP);
  pinMode(button2Pin, INPUT_PULLUP);
  pinMode(button3Pin, INPUT_PULLUP);
  pinMode(buzzerPin, OUTPUT);
}

void loop() {
  int potValue = analogRead(potPin);
  // Map potentiometer to a modulation range
  int modulation = map(potValue, 0, 1023, -100, 100);

  if (digitalRead(button1Pin) == LOW) {
    tone(buzzerPin, noteC + modulation); // Button 1: C note modulated
  } else if (digitalRead(button2Pin) == LOW) {
    tone(buzzerPin, noteE + modulation); // Button 2: E note modulated
  } else if (digitalRead(button3Pin) == LOW) {
    tone(buzzerPin, noteG + modulation); // Button 3: G note modulated
  } else {
    noTone(buzzerPin);
  }
}

A Brief Rant on the Future of Interaction Design

Reading “A Brief Rant on the Future of Interaction Design” genuinely made me pause and reconsider the direction of our relationship with technology. The author’s central argument- that today’s touchscreens, while innovative, are ultimately constraining- really struck a chord with me. I often marvel at how intuitive my phone is, yet I can’t help but notice how it reduces all my interactions to tapping and swiping on a flat surface. The analogy to early black-and-white cameras is particularly effective; just as those cameras were revolutionary yet obviously incomplete, so too are our current devices. The reference to Matti Bergström’s research about the richness of tactile sensation in our fingertips is compelling evidence that we are sacrificing a significant aspect of our cognitive and sensory development for convenience.

However, I found myself questioning the author’s rather dismissive stance on voice interfaces and gesture controls. While I agree that voice commands can’t replace the hands-on nature of artistic or spatial work, I think the author underestimates their value. Personally, I find voice assistants incredibly useful for multitasking or quick information retrieval- tasks where speed and efficiency matter more than depth of interaction. The author’s point about deep understanding requiring active exploration is well taken, but I believe there’s space for a variety of input methods, each suited to different contexts.

The text also made me reflect on the broader consequences of how we use technology. The idea that we are “giving up on the body” by designing tools that encourage us to be sedentary is quite thought-provoking. I hadn’t previously considered how interface design could contribute to a less physically engaged lifestyle. This perspective encourages me to be more mindful of how I use technology, and to seek out more physically interactive experiences where possible.

In summary, this rant has prompted me to think more deeply about what I want from the future of interaction design. While I appreciate the accessibility and simplicity of modern devices, I agree that we shouldn’t settle for tools that limit our physical and intellectual potential. The text serves as a powerful reminder that technology should enhance our full range of human abilities, not just cater to convenience.

Week 10 – Reading Response

A Brief Rant on the Future of Interactive Design + Follow-up

The first minute of the Microsoft video envisioning the future seemed really cool to me, but as it went on, the video kept repeating the same ideas over and over again. It felt like our future was limited to one or two movements. The rant definitely opened up my eyes to the subconscious abilities our hands possess. Maneuvers and motions we’ve been doing since young have become so natural we don’t realize just how powerful this sense is. The rant and response to comments made about the rant reminded me of the movie Wall-E where in the distant future, all the humans become so reliant on screens, they become unable to use their body. Living life through a screen when we’re blessed with so many degrees of motion immobilizes you; we see it even now as people get more glued to screens and are constantly sitting or lying down. I do wonder though what some potential solutions to this “picture under glass” future would be. I’m thinking about somehow incorporating textures, weight, and 3D objects because the main problems mentioned were how our hands have the ability to sense and manipulate things from touch, but a 2D glass screen avoids all of that. Or maybe centering designs around actions we can perform like flipping pages, pinching things, twisting, squishing, etc. Maybe even taking inspiration from bigger actions like planting flowers,  steering and feeling the torque of the wheel, or feeling water and how it sways under the force of your hands.

Week 10 Reading

The part of this article that stuck out to me the most was when the word “tool” was defined. I had never thought of a tool as something that was supposed to amplify human capabiity, yet when he explained his reasoning, using the example with the hammer, it all clicked for me. This meant that when he then goes on to explain the lack to tactile richness in modern day tools as a problem, it makes far more sense for me to see it as a problem.

He then points out that touchscreens should be only a transitionary technology. This really points out the possibilities that I have nver considered due to our complacency in screen usage. I think that being able to control something with our fingers, by dragging something along on a touchscreen is inherently somewhat unnnatrual in terms of what the human mind and body are used to; it is simply an unnatrual way to manipulate ‘objects.’ Yet I believe that in terms of how far away that takes us from perfect design with tactile responses, I would not overlook the human mind’s capacity to ‘fill in the blanks’ and ascertain all that we need to know from the object on the screen. So I personally do not think it is as much of an issue as the article says.

Week 8 – Unusual Switch

When thinking of an unusual switch, I looked for something that is less used in the kit and unconventional. I chose to explore how I can use the temperature sensor creatively as a switch. When thinking of the same, I realized most air conditioning units require manual input which may be an inconvenience to people who have specific and fixed room temperature requirements. I therefore decided to create a program that can be preset so that the AC unit can adjust automatically as it has been configured. For the MVP I had one LED light to show the change in temperature such that it lit when the temperatures went above a certain threshold and went off when the temperatures reduced below a certain level. I later added two more LED lights so that together with the three led lights could show the signal when the temperature was within certain ranges. Why is this important? This program could be modified and connected to a thermostat so that instead of only turning the A/C on and off, one could set it to self-modify the temperatures when the room temperature is at a certain level without necessarily changing it manually.

CODE HIGHLIGHTS

The only part that was slightly challenging was converting the reading from the TMP36 to voltage and later on to degrees celsius. I realized that the TMP36 sensor has a linear output of 10mV per °C, with an offset of 500mV at 0°C. And therefore to convert to volts and degrees I used the following block of code;

void loop() {
  reading = analogRead(A0);  // read analog pin
  volts = reading * aref_voltage / 1023.0; // convert to voltage
  millivolts = 1000 * volts; // convert to millivolts
  degreesC = (millivolts - 500)/10;  // convert to deg C
  degreesF = (degreesC * 9/5) + 32;  // convert to deg F

 

IMAGES AND DEMO

REFLECTIONS AND FUTURE IMPROVEMENTS

Using the temperature sensors was fun but as the Professor noted in one of the classes it can be a boring tool in the sense that it takes long to actually test it’s efficacy owing to the rigidity of the independent variable – temperature. Going forward I’d love to make projects that are more user friendly and more interactive that is; makes more use of the physical things around us. Also, I definitely will be exploring the other items in the toolkit even more.

Demonstration Video

To analyze the thermal response of the circuit, I positioned it near the heat emission area of my laptop, then incrementally increased the distance to observe variations in temperature effect

Demonstration

 

Assignment 9: Digital and Analogue Detection

This is my Analogue and Digital device sensing machine. It uses an Ultrasonic sensor and Push button to change the brightness of LEDs and to toggle them on/off.

Assignment Brief

  • Get information from at least one analogue sensor and at least one digital sensor
  • Use this information to control at least two LEDs, one in a digital fashion and the other in an analog fashion
  • Include a hand-drawn schematic in your documentation

Conceptualisation

The idea for this project was inspired by the desire to create an interactive system that responds to both user input and environmental conditions. I wanted to design a setup where users could actively engage with the system while also observing dynamic feedback. By using an ultrasonic sensor as the analog input, I aimed to create a setup where distance could influence the brightness of an LED, making it visually engaging. Additionally, I incorporated a pushbutton as the digital input to provide manual control over another LED, allowing for a tactile interaction. This combination of sensors and LEDs was chosen to demonstrate how analog and digital inputs can work together in a creative and functional way.

Process

  1. Component Selection: I gathered an Arduino board, an Ultrasonic Sensor (HC-SR04), LEDs, Resistors, Pushbutton Switch, and Jumper Wires

  2. Circuit Assembly: I connected the ultrasonic sensor to the Arduino, ensuring proper wiring for its VCC, GND, TRIG, and ECHO pins. I connected the pushbutton switch to one of the digital pins on the Arduino with an internal pull-up resistor. I wired two LEDs: one LED was connected to a PWM pin for analog brightness control; the other LED was connected to a digital pin for simple on/off functionality.

  3. Code Development: I wrote Arduino code that: Reads distance data from the ultrasonic sensor; maps the distance data to control the brightness of one LED using PWM; reads input from the pushbutton switch to toggle another LED on or off. The code also included debugging statements for monitoring sensor data via the Serial Monitor.

  4. Calibration: I tested and calibrated the ultrasonic sensor by experimenting with different distance thresholds. This involved adjusting the mapping range for brightness control and ensuring accurate detection of distances within 100 cm. For the pushbutton, I verified its functionality by toggling the digital LED on and off during testing.

Challenges

  1. Sensor Accuracy: The ultrasonic sensor occasionally gave inconsistent readings due to interference or non-flat surfaces. To address this, I ensured proper alignment of objects in front of the sensor during testing

  2. False Triggers: Early versions of the code caused unintended behavior due to incorrect wiring and delays in signal processing. I resolved this by carefully re-checking connections and optimizing delay times in the code

  3. Brightness Mapping: Mapping distance values (0–100 cm) to PWM brightness (0–255) required fine-tuning to achieve smooth transitions in LED brightness.

Potential Improvements

  1. Multiple Sensors: Adding more ultrasonic sensors could allow for multi-directional distance sensing, enabling more complex interactions.

  2. Enhanced Visual Feedback: Using RGB LEDs instead of single-color LEDs could provide more dynamic visual responses based on distance or button presses.

  3. Energy Efficiency: Exploring low-power modes and more efficient components could extend battery life for portable applications.

Schematic Diagram

Source Code

// Pin assignments
const int trigPin = 7;       // Trig pin for ultrasonic sensor
const int echoPin = 6;       // Echo pin for ultrasonic sensor
const int buttonPin = 2;     // Digital pin for pushbutton
const int ledAnalogPin = 9;  // PWM pin for analog-controlled LED
const int ledDigitalPin = 13; // Digital pin for on/off LED

void setup() {
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(buttonPin, INPUT_PULLUP); // Enable internal pull-up resistor
  pinMode(ledDigitalPin, OUTPUT);
  pinMode(ledAnalogPin, OUTPUT);

  Serial.begin(9600); // For debugging
}

void loop() {
  // Measure distance using ultrasonic sensor
  long duration, distance;
  
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  
  digitalWrite(trigPin, LOW);
  
  duration = pulseIn(echoPin, HIGH);
  
  // Calculate distance in centimeters
  distance = duration * 0.034 / 2;

  // Map distance (0-100 cm) to PWM range (0-255)
  int brightness = map(distance, 0, 100, 0, 255);

  // Control brightness of analog-controlled LED
  analogWrite(ledAnalogPin, brightness);

  // Read pushbutton state
  int buttonState = digitalRead(buttonPin);

  // Toggle digital-controlled LED based on button press
  if (buttonState == LOW) { // Button pressed
    digitalWrite(ledDigitalPin, HIGH);
  } else {
    digitalWrite(ledDigitalPin, LOW);
  }

  // Debugging output
  Serial.print("Distance: ");
  Serial.print(distance);
  Serial.print(" cm | Brightness: ");
  Serial.println(brightness);

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