Final Project Idea 2

Concept:

Create an automatic trash can that uses sensors to detect and sort different types of waste (plastic, paper, etc.) into separate compartments within the can. The system will utilize Arduino for hardware control and p5.js for a user interface to monitor and interact with the trash can.

Components:

  1. Arduino Uno
  2. Ultrasonic sensors or weight sensors to detect the type of waste being disposed of.
  3. Servo motors or stepper motors to control the compartments for different types of waste.
  4. P5.js for the user interface to monitor the trash can’s status and possibly interact with it.

Arduino (Outgoing Data):

Detecting and Sorting: Arduino reads sensor data to detect the type of material placed in the trash can. Based on this detection, it activates servo motors to sort the materials into their respective compartments.
Serial Communication: Once the material is detected and sorted, Arduino sends updates about the detected material type and sorting process status via the Serial connection.

p5.js (Outgoing Commands):

p5.js sends commands/instructions to the Arduino via the Serial connection, requesting the disposal of a particular type of waste.

Arduino (Incoming Commands):

Receiving Instructions: Arduino listens for incoming commands from p5.js through the Serial connection. It interprets these commands to initiate the disposal process.
Status Queries: Arduino responds to queries from p5.js by sending updates on the system status, like whether it’s ready to receive new commands or the current state of the sorting mechanism.

p5.js (Incoming Data):

Display and Feedback: p5.js receives data from Arduino about detected materials and system status.

Final Project Draft 2: HFR

Concept
In my previous blog post, I introduced the idea of creating a Human Following Robot inspired by sci-fi movies like Wall-E. The concept revolves around developing a robot companion that autonomously follows a person, adjusting its position based on their movements. This project aims to bring a touch of cinematic magic into real life by utilizing sensors as the robot’s eyes and ears, allowing it to perceive the presence and actions of the person it follows.

Key Components
1. Ultrasonic Sensor:
Role: Measures the distance between the robot and a person.
Functionality: Enables the robot to make decisions about its movement based on the person’s proximity.
2. DC Motors and Motor Driver:
Role: Facilitates the robot’s movement.
Functionality: Allows the robot to move forward, backward, and turn, responding to the person’s position.
3. Servo Motor:
Role: Controls the direction in which the robot is facing.
Functionality: Adjusts its angle based on the horizontal position of the person, ensuring the robot follows the person accurately.
4. P5.js Integration:
Role: Provides visualization and user interface interaction.
Functionality: Creates a graphical representation of the robot’s perspective and the person’s position. Visualizes the direction of the servo motor, offering a clear indicator of the robot’s orientation.

Finalized Concept
Building upon the initial concept, the finalized idea is to implement a real-time human following mechanism. The robot will utilize the input from the ultrasonic sensor to determine the person’s distance, adjusting its movement accordingly. The servo motor will play a crucial role in ensuring the robot faces the person, enhancing the user experience.

Arduino Program
Inputs: Ultrasonic sensor readings for distance measurement.
Outputs: Control signals for DC motors based on a person’s proximity.

Video 1

P5 Program
The P5 program will focus on creating a visual representation of the robot’s perspective and the person’s position. It will receive data from the Arduino regarding the robot’s orientation and the person’s horizontal position, updating the graphical interface accordingly. (I’m thinking of representing an ellipse where the closer you are to the sensor the smaller the ellipse and the further you are the larger it gets). Furthermore, I have tried to implement a clickable control in p5 where it can move the robot frontwards and backwards by clicking on the right and left side of the p5 sketch.

Video 2 

 

Final Project so far:

I have been looking into the machine learning library, and so far, I have achieved the poseNet creation for the palms but I am now looking into how this can be used to control my steering wheel. What steering wheel you might be wondering. So I have created a steering wheel that I plan to use to control the wheels of the car I would create. That is if I should choose to create a car. The p5 sketch for the steering wheel so far is below

So I continue to look into how to do the integration but for the ML so far this is what I have below:

Its not much but its cooking. Inshallah!

Alien Intelligence w/Professor Leach

 

I was so happy to attend Professor Leach’s talk about AI! The conversation of AI has recently come up in a discussion with some of my peers and it reminded me of a few of the topics that were discussed in Professor Leach’s talk. In conversation, we were discussing the role of AI in the arts and how AI can be quite harmful to artists, at least that’s what I believe. My friends disagreed (quite loudly if I may add) and maintained the stance that AI will never be able to create art in the same way a human can. They went on to say that you simply can’t program creativity, so AI would be unlikely to replace human artists.

Here are my thoughts.

As an artist myself, I feel that we are entering a very tricky time. For me, it isn’t about my art vs the AI-generated art. It’s more so these questions: Will people be able to tell the difference or care who made the art? Will art become devalued and seen as something that can be simply generated by AI? Why would you pay for artists and their work when you can recreate their work or make something even more artificially “perfect” with AI?

These questions have yet to be answered and are quite difficult to answer. I wonder what the future will look like for artists who ultimately will have to compete with not only other artists like themselves, but AI as well.

 

FINAL PROJECT PROPOSAL

For my final project, I wanted to do something that was related to sound since I have a great interest in all things music/sound-related. After much research and contemplation, I decided to recreate one of the most important tools in my line of work, a midi controller. I use my MIDI controller for all of my musical creations because it is not only convenient but works incredibly well with my DAWs (digital audio workstations). The primary instrument that I use in many of my pieces is the synthesizer. This instrument inspires so many of my songs and allows me to manipulate sound in ways I could have never imagined. 

For this project, I will be taking inspiration from this tutorial ( https://www.youtube.com/watch?v=cHiTPoNCv1w ) and recreating my own controller. I hope to have quite a few buttons that will mimic a synthesizer and also add some sound effects for percussion (like a drum kit). I have yet to figure out how I want to implement p5 in all of this but I am thinking of trying to create a sound visualization in p5 that will maybe move whenever a button in Arduino is pressed. 

 

Here is the sample code for the Arduino portion of my project.

#include <Control_Surface.h> // Include the Control Surface library

// Instantiate a MIDI over USB interface.
USBMIDI_Interface midi;

// Instantiate a NoteButton object
NoteButton button {
  5,                             // Push button on pin 5
  {MIDI_Notes::C(4), Channel_1}, // Note C4 on MIDI channel 1
};

void setup() {
  Control_Surface.begin(); // Initialize Control Surface
}

void loop() {
  Control_Surface.loop(); // Update the Control Surface
}

These are the two sound libraries that I needed to download for this code to make a bit more sense.

https://github.com/arduino-libraries/MIDIUSB

https://tttapa.github.io/Control-Surface-doc/Doxygen/index.html

I attempted to draw the basic circuit 😔

Week 11 : Assignment (Mudi & Mariam)

 

Exercise 1

In this exercise, a potentiometer connected to an Arduino has been employed to influence the horizontal movement of an ellipse in p5.js. As you turn the potentiometer, the ellipse smoothly moves from side to side.

Exercise 2 :

Concept: Controlling the brightness of an LED using a slide bar in p5js

The left side of the slide bar (owl) will dim the brightness of the LED and the right side of the slide bar (sun) will make the LED brighter. We used the PWM pin 5 for the LED
a 10 K ohm resistor and two jumper wires to make the connection

code :

let brightness = 0; 
let slider;
let img;

//preload images to make sure everything is loaded before initializing the rest of the code
function preload(){
  img= loadImage('sun.png');
  img2 = loadImage('owl.png');
}
function setup() {
  createCanvas(400, 400);
  //create slider
  slider = createSlider(0, 255, 100);
  slider.position(width/2-50,height/2+130);
  slider.style('width', '80px');
}
function draw() {
  background('black');
  image(img,235,130,130,180); 
  image(img2,10,140,160,160);
  
  let val = slider.value();
  brightness = val;
  
  // instructions
  textAlign(CENTER,CENTER);
  textSize(12);
  fill(255)
  textStyle(BOLD)
  text("Controling the brightness of the LED using the slider ",width/2,100);
  
  //connects the serial port
  if (!serialActive) { 
    textSize(10);
    text("Press Space Bar to select Serial Port", 100, 30);
  } else {
    textSize(10);
    text("Connected",100,30);
  }
   
  

 

 

Week 11 Exercises

 

(Mudi & Mariam)

Exercise 1

In this exercise, a potentiometer connected to an Arduino has been employed to influence the horizontal movement of an ellipse in p5.js. As you turn the potentiometer, the ellipse smoothly moves from side to side.

Exercise 2 :

Controlling the brightness of an LED using a slide bar in p5js
Concept:

The left side of the slide bar (owl) will dim the brightness of the LED and the right side of the slide bar (sun) will make the LED brighter. We used the PWM pin 5 for the LED
a 10 K ohm resistor and two jumper wires to make the connection

 

Arduino Code:

int redled = 5; //PWM PIN
void setup() {
  pinMode(redled, OUTPUT);
  Serial.begin(9600);
  
  
  // initializing handshake
  while (Serial.available() <= 0) {
    Serial.println("a moment");  
    delay(200);               // wait 1/2 second
  }
}
void loop() {
  // wait for data to load from p5 before continuing code
  while (Serial.available()) {
    int brightness = Serial.parseInt(); 
    if (Serial.read() == '\n') {
      analogWrite(redled, brightness); // turn on LED and adjusts brightness
      Serial.println("ON"); 
    }
  }
}

 

Final Project Draft 1: Dodge it!

Concept:

For my final project, I pursued my initial idea and created a game that utilizes the ultrasonic sensor. The ultrasonic sensor will measure the distance from my hand and project that distance onto a ball’s horizontal position in p5. The ball can move left and right according to our hand movement. Multiple red rectangles are falling from above, and our job is to dodge them using our hands. There are also blue rectangles that spawn less frequently compared to the red ones. There is also a scoring system in which the score decreases by one after every frame, and hitting the red rectangles decreases the score by 2. Grabbing the blue rectangles that spawn less frequently is the only way to get a higher score. So the game becomes a fight against time and obstacles. As the score changes, the speaker that is connected to the breadboard also produces a different tone. Each score has its own unique tone produced by the speaker to make the game more engaging and fun. Therefore, this is a 2-way communication game, from p5 to Arduino and Arduino to p5.

Arduino:

Arduino will basically send the distance measured using the ultrasonic sensor to p5.Js. The Arduino side of the code will receive a score value from the p5. Arduino will input the echo pin(from ultrasonic sensor reading)  and outputs both the trig pin(from ultrasonic) and speaker pin(value received from p5).

Here is my code for it so far:

const int trigPin = 11;
const int echoPin = 12;
const int speakerPin = 9;

void setup() {
  // Start serial communication so we can send data
  // over the USB connection to our p5js sketch
  Serial.begin(9600);
  pinMode(LED_BUILTIN, OUTPUT);

  // Outputs on these pins
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(speakerPin, OUTPUT);

  //start the handshake
  while (Serial.available() <= 0) {
    digitalWrite(LED_BUILTIN, HIGH); // on/blink while waiting for serial data
    Serial.println("0,0"); // send a starting message
    delay(300);            // wait 1/3 second
    digitalWrite(LED_BUILTIN, LOW);
    delay(50);
  }
}

void loop() {
  // sends a short pulse of ultrasonic sensor and waits a bit then receives it 
  digitalWrite(trigPin, LOW); 
  delayMicroseconds(2); 
  digitalWrite(trigPin, HIGH); 
  delayMicroseconds(10); 
  digitalWrite(trigPin, LOW); 

  // Time it takes for the pulse to travel back from the object long 
  int duration = pulseIn(echoPin, HIGH); 
  // Universal conversion of time into distance in cm 
  int distance = duration * 0.034 / 2;

  //SENDS TO P5
  Serial.println(distance);
  delay(50);

  //GETS FROM P5
  int score = Serial.parseInt();
  // Map the score to a frequency for the speaker
  int frequency = map(score, 0, 100, 100, 4000);
  // Play the tone
  tone(speakerPin, frequency);
}

The Arduino board:

p5:

For the p5 side of the code, the p5 will receive the distance value measured from Arduino and map it onto the canvas. The p5 will also send a live score value to Arduino. There are multiple classes to my p5 code: ball class, Obstacle class, TimeRectangle class, a class for the port connection, and finally the main sketch.

This is my attached main sketch class:

//Initialize all variables
let knobValue = 0;
let targetKnobValue = 0;
let easing = 0.08; // Adjust this value for the desired level of smoothing
let score = 0;
let lastFrameCount;

//initialize the class objets
let obstacles = [];
let timeRectangles = [];
let ball;


function setup()
{
  createCanvas(400, 300);
  //call the ball object
  ball = new Ball(width / 2, height - 30, 20);
  //line of code to set lastframe to the new one
  lastFrameCount = frameCount;
}

function draw() {
  //set background
  background(220);

  //if function to connect port 
  if (!serialActive)
  {
    fill(0);
    textSize(18);
    text("Press Space Bar to select Serial Port", 20, 30);
  } 
  //else function if the port is connected
  else 
  {
    // lerp function linear interpolates(smoothes the value we get from arduino using distance sensor)
    knobValue = lerp(knobValue, targetKnobValue, easing);
    //updates ball position according to distance sens
    ball.update(knobValue);

    // Draw ball
    ball.show();

    // Draw and move obstacles
    for (let i = obstacles.length - 1; i >= 0; i--) {
      obstacles[i].update();
      obstacles[i].show();

      // Remove obstacles that are off-screen
      if (obstacles[i].offscreen()) {
        obstacles.splice(i, 1);
      } else {
        // Check for collision with the ball
        if (obstacles[i].collision(ball)) {
          // Handle collision (e.g., decrease score)
          score= score-2;
          obstacles.splice(i, 1); // Remove the obstacle
        }
      }
    }

    // Draw and move timeRectangles(blue ones)
    for (let i = timeRectangles.length - 1; i >= 0; i--) {
      timeRectangles[i].update();
      timeRectangles[i].show();

      // Remove timeRectangles that are off-screen
      if (timeRectangles[i].offscreen()) {
        timeRectangles.splice(i, 1);
      } else {
        // Check for collision with the ball
        if (timeRectangles[i].collision(ball)) {
          // Handle collision (e.g., increase score)
          score += 5;
          timeRectangles.splice(i, 1); // Remove the timeRectangle
        }
      }
    }

    // Print the current knobValue
    fill(0);
    textSize(18);
    text('Knob Value: ' + str(knobValue), 20, 30);

    // Display score
    text("Score: " + score, 20, 60);

    // Spawn new obstacles and timeRectangles randomly
    if (random() < 0.01) {
      obstacles.push(new Obstacle());
    }
    if (random() < 0.005) {
      timeRectangles.push(new TimeRectangle());
    }
    
       // Update the score every second by subtracting current frame with last frame recorded in setup
    if (frameCount - lastFrameCount >= 60) {
      score = max(0, score - 1);
      lastFrameCount = frameCount;
    }
    
  }
}

function keyPressed() {
  if (key == " ") {
    // important to have in order to start the serial connection!!
    setUpSerial();
  }
}

function readSerial(data) {
  ////////////////////////////////////
  // READ FROM ARDUINO HERE
  ////////////////////////////////////

  if (data != null) {
    // Parse the data received from Arduino
    let fromArduino = split(trim(data), ",");
    targetKnobValue = int(fromArduino[0]);
    print(targetKnobValue);
  }

  //////////////////////////////////
  // SEND TO ARDUINO HERE
  //////////////////////////////////
  let sendToArduino= score + "\n";
   writeSerial(sendToArduino);
}

The P5 interface:

Future improvements:

As of now, I just put down the main codes and functions for both platforms. I will have to work more on the visuals, designs, and aethstics side as a whole of the p5 game.

 

Alien Intelligence w/Professor Leach

Attending professor’s Leach conference about his opinion about AI is certainly an interesting experience. He mostly spoke about how AI is this extremely smart web that connects all human minds and thoughts into one place, making it smarter than 5 people combined. Professor Leach praises the concept that AI is an extremely helpful tool that is open to all. 

My thoughts were mostly concerned with ethics. Should we as a community come up with regulations and a set of requirements to not make others use AI for their advantage. As an artist who mostly uses digital art (tablet and pen) I think people need to realize how harmful it is to use AI tools without proper manners. In the end AI is made from people’s thoughts and work, if people get used to “creating” art whether it be a drawn piece or a song I personally would consider it theft. Because it uses copies of other artists to replicate what a person wants. It might be fine to have it for personal use, however publicly claiming their own hard work is a little shameful. 

I really think regulations should be set for AI, and people should be mindful of the type of work they do.