Task 1
This task is aimed to send data from Arduino to Processing. The first step is to read the two potentiometers’ values and send them to Processing. Below is the code on Arduino.
Arduino(send multiple values code):
https://gist.github.com/LafouCC/9af12c8988c926be649ce9be3a6d86ef
Then, we receive the values on Processing, and we use the values to decide the X, Y position of a circle with the help of the function “map”.
Processing (draw a circle code):
https://gist.github.com/LafouCC/c88644e2637c1cbe603cc9ee1d8d3215
Then, in order to expand the possibilities of the drawing, I use the values to draw lines to form a drawing. In this step, you have to define the previous positions and the current positions of X, Y to form a line. So, instead of using the traditional pen to draw, this task provides us with a new perspective on drawing tools and ways.
Processing(line code):
https://gist.github.com/LafouCC/1154432b44c171282c6fc639f2b64ad0
Task 2
This task is aimed to send data from Processing to Arduino. As for my teammate, I work with Wendy. I’m in charge of the Arduino coding while Wendy is in charge of drawing in Processing. Below, is what we got (we change the original circle into a star to make it fancier).
The interaction involved is the communication between 2D animation in Processing and the 3D servo movement controlled by Arduino. It kind of reminds me of the second project I mentioned in the Final Project-Research post, connecting the 2D world with the 3D world (what you do in reality affects what you see on screen).
Processing (draw a star code):
https://gist.github.com/LafouCC/4b4c49c96767b92c9bcf554add126df6
Arduino (send x position code):
https://gist.github.com/LafouCC/fa4583d88435365aff5345a612c69964
Reflections:
1. the effect comes from overlapping semi-transparent rectangles.
fill(#232640, 50); rect(0, 0, width, height);
2. do the coding in Arduino instead of processing:
I first think of judging the X position on Processing and sending a signal to Arduino to activate the servo, but later found that it is better to do the coding on Arduino, so I only need to send the x position to Arduino.