Posts

Showing posts from October, 2019

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