1. I didn’t know what we were doing after watching the video. so I consulted a learning assistant who told me that it is using the potentiometers to draw pictures. so I first downloaded the initial code successfully can found it worked. the ball can move as my potentiometers move. then the question is how to make the trace materialize because now we can not see its trace. so I asked professor Rudi how to do it and he told me to define a line from the previous position of the ball to the current position of the ball. that’s exactly what I did but still, I couldn’t see the trace. then Christine the learning assistant told me the reason which is the problem of background. because my previous setup made the black background cover the trace once it is drawn because it is outside the loop. so I move the setup of the background inside the loop and then I can see the traces.
2. what I have learned is that we should check what is inside the loop and what is not before running the whole process. the whole process mainly go as planned and I succeeded on my second try. the interaction involved is using the potentiometers and there will be patterns on the screen. after seeing what we have drawn, we can then decide our next step in drawing which is interactive.
3. here are the pictures and videos
4. here are the codes
/** * Example sketch for the SerialRecord library for Processing. * * Receives two integers from the serial port, and uses them to control the x * and y position of a circle on the canvas. */ import processing.serial.*; import osteele.processing.SerialRecord.*; Serial serialPort; SerialRecord serialRecord; float prex; float prey; void setup() { size(500, 500); prex = 0; prey = 0; background(0); String serialPortName = SerialUtils.findArduinoPort(); serialPort = new Serial(this, serialPortName, 9600); // If the Arduino sketch sends a different number of values, modify the number // `2` on the next line to match the number of values that it sends. serialRecord = new SerialRecord(this, serialPort, 2); } void draw() { serialRecord.read(); int value1 = serialRecord.values[0]; int value2 = serialRecord.values[1]; float x = map(value1, 0, 1024, 0, width); float y = map(value2, 0, 1024, 0, height); //circle(x, y, 20); stroke(255); strokeWeight(10); line(prex, prey, x, y); prex = x; prey = y; }
/* SendMultipleValues Reads an analog input on pin 0, and sends a record that contains two values: 1. Value of `millis()`, modulo 1024. 2. The analog value that is read from pin 0. If you attach a potentiometer to pin 0, you can control this value by moving the pot. This sketch pairs well with the RecieveMultipleValues example from the Processing SerialRecord library <https://osteele.github.io/Processing_SerialRecord/>. Things to try: - Connect a second potentiometer to the Arduino, and send the values from both potentiometers, instead of send a value that is based on `millis()`. - Send the value from another sensor, such as temperature or proximity. by Oliver Steele, 2020-2022 This example code is in the public domain. */ #include "SerialRecord.h" // Change this number to send a different number of values SerialRecord writer(2); void setup() { Serial.begin(9600); } void loop() { int sensorValue = analogRead(A0); int sensorValue1 = analogRead(A1); writer[0] = sensorValue1; writer[1] = sensorValue; writer.send(); // This delay slows down the loop, so that it runs less frequently. This can // make it easier to debug the sketch, because new values are printed at a // slower rate. delay(10); }
5. the second project goes rather roughly because I couldn’t get the signal passed from Arduino to Processing. the name of my teammate is Joy. almost everything didn’t go well. we first download the initial two codes and then we are stuck on how to make the ball bounce. so we approached the learning assistant Iris and she assist us in making the ball bounce. we first fail to understand the mathematical theory behind the code so our ball will bounce beforehand. after some math calculations concerning radius and diameter, we successfully made the ball bounce as is shown. then comes the problem of transmitting the information to the procession and making the motor move. after consulting professors and other classmates, we succeeded in making our code right. but still, the motors do not move or move just once and stopped moving ever since. after consulting Iris the learning assistant, we found we open the Processing before Arduino which made all the problems. after adjusting the sequence we succeed.
6. what we have learned from this project is to smartly use the resources on the internet and make it the prototype of our code. also, we know how to send signals from Arduino to Processing. the interaction in this project is between the motors and the balls. the two objects do not have consciousness but they can still interact with each other without needing to understand the other’s meaning.
7. here are the videos.
8. here are the codes
/* ReceiveMultipleValues This sketch repeatedly receives a record that contains a single value, and uses it to control the builtin LED. The value should be 0 or 1. This sketch pairs well with the SendSingleValue example from the Processing SerialRecord library <https://osteele.github.io/Processing_SerialRecord/>. You can also interact with this sketch from the Serial Monitor. Enter `100,200` into the text area at the top, and press "Send". Then enter `!e` to ask the Arduino to send back the last values it received. by Oliver Steele, 2020-2022 This example code is in the public domain. */ #include "SerialRecord.h" // Change this number to the number of values you want to receive SerialRecord reader(1); #include Servo myservo1; // create servo object to control a servo Servo myservo2; int potpin = 0; // analog pin used to connect the potentiometer int val; // variable to read the value from the analog pin void setup() { Serial.begin(9600); myservo1.attach(8); // attaches the servo on pin 8 to the servo object myservo2.attach(5); // attaches the servo on pin 5 to the servo object } void loop() { if(reader.read()){ if(reader[0] == 0){ // do one movement here myservo1.write(180); // sets the servo position according to the scaled value delay(200); myservo1.write(0); }elseif(reader[0] == 1){ myservo2.write(180); // sets the servo position according to the scaled value delay(200); myservo2.write(0); // do another movement there } } }
/** * Example sketch for the SerialRecord library for Processing. * * Maps the horizontal and vertical position of the mouse on the canvas to the * range 0…1023, and sends them to the serial port. */ import processing.serial.*; import osteele.processing.SerialRecord.*; Serial serialPort; SerialRecord serialRecord; int rad = 60; // Width of the shape float xpos, ypos; // Starting position of shape float xspeed = 2.8; // Speed of the shape int xdirection = 1; // Left or Right void setup() { size(500, 500); ypos = 250; xpos = 61; String serialPortName = SerialUtils.findArduinoPort(); serialPort = new Serial(this, serialPortName, 9600); // In order to send a different number of values, modify the number `2` on the // next line to the number values to send. In this case, the corresponding // number in the Arduino sketch should be modified as well. serialRecord = new SerialRecord(this, serialPort, 1); } void draw() { background(0); // Update the position of the shape xpos = xpos + ( xspeed * xdirection ); if (xpos > width - rad/2 || xpos < rad/2) { xdirection *= -1; if (xpos > width - rad/2) { serialRecord.values[0] = 0; serialRecord.send(); } else { serialRecord.values[0] = 1; serialRecord.send(); } } // Draw the shape ellipse(xpos, ypos, rad, rad); }