Team member: Jueun Jeon, Yuri Kim, Amogh Gharpure




Project goal

To utilize Arduino for replacing 3 mouse functions and displaying the result via p5.js.

We used the translate function(axis x, axis y) and the left click of a mouse as the 3 functions for this project. The potentiometer strip controls the axis x, the potentiometer controls y, and the push button works like a mouse click.

Preparation

We used a Linear soft Potentiometer strip, Potentiometer, and a button for achieving the goal.

Attempt 1:

Initially, we used handshaking examples from the lab class and updated both Arduino and p5.js code to be able to get three valuables from three sensors. However, p5 was not receiving the values from Arduino.

Serial.print(sensorVal1); // potentiometer strip
Serial.print(",");
Serial.println(sensorVal2); // potentiometer
Serial.print(",");
Serial.println(sensorVal3); // push button
// value1, value2,
// value3

The cause was the println() function which printed it to next line, so we modified it to print();

Serial.print(sensorVal1);  // potentiometer strip
Serial.print(",");
Serial.print(sensorVal2); // potentiometer
Serial.print(",");
Serial.print(sensorVal3); // push button
//value1, value2, value3

Attempt 2:

Mapping the data to adjust the output on the right spot on the screen.

	  sensorVal1 = map(sensorVal1, 0, 1200, 0, 1000);
    sensorVal2 = analogRead(sensorPin2);
    sensorVal2 = map(sensorVal2, 0, 1000, 0, 1000);
    sensorVal3 = map(digitalRead(2), 0, 1, 0, 255);