Posts

FINAL PROJECT

Image
My Final Project is a sound piece company with a visual projection using  an analog sensor and P5 sketch . By using the ultrasonic module distance sensor I want to program three trigger points to activate three different sounds to make an immersive installation. The project is hope experiment  with an analog sensor reacts to the P5 sketch program that communicates to an Arduino. The installation is designed so people can walk around and interact with the sound and even add their own sound to trigger the visual activation.  P5 Code for sound activation: 3 different trigger points to set the sound off. https://editor.p5js.org/heestar-knotty/sketches/37DNwFe2S P5 code for visual activation: The line drawing reacting to the volume of the sound.  https://editor.p5js.org/heestar-knotty/sketches/ZJJi033hd I had two computers work simultaneously to make this installation. One dedicated to my sound activation and one for the visual activation.  Here is the recording of the

Final Project Proposal

Image
Working title: Trio Tiro is a sound piece company by a visual projection using  an analog sensor and P5 sketch . By using the ultrasonic module distance sensor I want to program three trigger  point to activate three different sounds or voices to make a melodious music. The project is hope experiment  with an analog sensor reacts to P5 sketch program that communicate to an arduino.

P5.js to Arduino

Image
task: Make something move, light up, or change in the physical world using output from a P5.js sketch. my first attempt failed. My p5 didn't responded.  I realized that I had the p5 code wrong so it worked once I ran the right coding. // WORKS IN CHROME // variable to hold an instance of the serialport library let serial; // !! fill in your serial port name here let portName = '/dev/tty.usbmodem24'; // for incoming serial data let inData;                        // for outgoing data let outByte = 0;                      function setup() {  createCanvas(400, 300); // make the canvas  // make a new instance of the serialport library  serial = new p5.SerialPort();   // callback for when new data arrives  serial.on('data', serialEvent);   // callback for errors  serial.on('error', serialError);  // open a serial port  serial.open(portName);          } function serialEvent() {  // read a byte from the serial port:

Motors

Image
To Do : Make something move. Try to use an analog sensor. Here is my schematic:  Connect power and ground on the breadboard to power and ground from the microcontroller. On the Arduino module, use the 5V or 3.3V (depending on your model) and any of the ground connections, as shown in Figures 9 and 10. Program the Microcontroller First, find out the range of your sensor by using analogRead() to read the sensor and printing out the results. And my motor worked:

Servo Motor Control with an Arduino

Image

Midterm projects, Analog output

Image
The sensor used:  ELEGOO 5PCS HC-SR04 Ultrasonic Module Distance Sensor   for Arduino UNO MEGA2560 Nano Robot XBee ZigBee Making sure the ultrasonic module distance sensor is connected and reading: P5:  https://editor.p5js.org/ heestar-knotty/sketches/9- BJ0SCFr function draw() {   background(255);   let safetyDistance = parseInt(latestData);   if (safetyDistance <= 50) {     background(random(255), random(255), 255);   } else {} } Resource link: https://www.elithecomputerguy.com/2019/06/hc-sr04-ultrasonic-distance-sensor-audio-alert-with-arduino/

p5 Interactivity

Image
By adding simple online " happyFace(mouseX, mouseY, pmouseX, pmouseY);" code I was able to write the reactionary code using the mouse. Code:  https://editor.p5js.org/heestar/sketches/DBuxceGCP Fullscreen: https://editor.p5js.org/heestar/full/DBuxceGCP I try to add code to react when the mouse is pressed but fail to active it.  if (mouseIsPressed == true) {     ellipse(x - offset, y - offset, eyeDiam, eyeDiam);     ellipse(x + offset, y - offset, eyeDiam_2, eyeDiam_2);   } Mouse click code: https://editor.p5js.org/heestar/sketches/a2UzX8ZYN // Smile   var startAng = .1 * PI   var endAng = .9 * PI   var smileDiam = .6 * diam;   //frown   var _startAng = -2.75   var _endAng = -6.55   var _smileDiam = .56 * diam;   strokeWeight(8);   arc(x, y, smileDiam, smileDiam, startAng, endAng);   if (mouseIsPressed == true)     //hide (arc(x, y, smileDiam, smileDiam, startAng, endAng));   arc(x, 575, smileDiam, _smileDiam, _startAng, _endAng); I can't get the existin