Exercise 1:
The first task is very similar to our in-class exercise. Therefore, by applying the sample code provided, I build up the circuit and modified the code quickly to make it work. For the circle task, I transmit two values from the Arduino to Processing. Then, I use these two values as the x and y of the center of the ellipse. Background refresh is a little tricky here. I will explain later. For some reason, it seems that my analog read A0 pin does not work… it took me a while to find this problem.
When it comes to drawing a line, it gives me the hint that “you will need to keep track of the previous x and y values.” Therefore, I recall the strategy that I often use when coding with Python. I try to declare two more variables to store the previous x and y value. Then, I can simply use the previous values and the new read values to draw a line. However, when I tried to run it, the canvas is completely blank. I soon realized that to make my previous drawing stay on the canvas, I should not reset the background every time. When I removed that line of code, it finally works.
During this exercise, the interaction happens between my “input” to adjust the potentiometer and the “output” graphs on the screen. This process enables me to CREATE a picture as I wish that it impact me to build constant communication between my thoughts and the drawing.
Exercise 2:
First, I read through the code in the file that enables me to transmit multiple values from Processing to Arduino. It is similar to the one that transmits values from Arduino to Processing.
Therefore, it is not difficult for me to understand the code. I decided to transmit three values in total: mouseX, mouseY, and whether the mouse is pressed. For the third one, I use “1” to indicate pressed, and “0” to indicate not pressed. I believe this would enable me to decode the information in Arduino easier.
I applied if statement to make the buzzer sounding while I click the mouse on the screen. The only problem I encountered is that I am not familiar with the function tone(). I checked the reference and got the basic idea that the variable determines the frequency of the tone, which makes it sounds differently. Then how could both the mouseX and mouseY input impact the sound? I figured out one way to simply add two values together to decide the frequency of the sound. It has the potential to be more creative if I could be more expert on the basic musical fundaments in the future.
The interaction process in this exercise is similar to exercise 1. Both of the exercises enable the user to CREATE something in their mind to develop and express the limitless imagination. The difference is the form of input and output. For exercise 2, it inputs the position of the mouse and outputs a tone.