Exercise 1:
This is what I’ve made.
This is the schematic:
This is the code I used in this exercise (I only put the code that excluded the provided example of AtoP here):
Processing
x = map(sensorValues[0],0,1023,0,500); y = map(sensorValues[1],0,1023,0,500); stroke(255); strokeWeight(5); line(x,y,px,py); circle(x,y,2.5); px = x; py = y;
Arduino
AtoP example
In this exercise, I think the main form of interaction is rotate two potentiometers and get the information about the position and show it on the computer screen. And the sketch that is shown on the computer screen can be seen by the users. This is the main interaction here.
Exercise 2:
This is what I’ve made:
I’ve taped the servo motors to my computer screen and added some decoration to make it more real.
This is the schematic:
This is the code I used in this exercise (I only put the code that excluded the provided example of PtoA here):
Processing
void setup() { //size(500, 500); fullScreen(); background(0); setupSerial(); values[0] = 15; } void draw() { background(0); values[1]=width; circle(values[0],height/2,30); values[0] = values[0]+t; if(values[0]>width-15 || values[0]<15){ t = -t; } Arduino
#include <Servo.h> Servo myservo1; Servo myservo2; void setup() { Serial.begin(9600); pinMode(13, OUTPUT); myservo1.attach(9); myservo2.attach(10); } void loop() { getSerialData(); if (values[0] == 15){ myservo1.write(90); delay(250); }else{ myservo1.write(0); } if (values[0] == values[1]-15){ myservo2.write(0); delay(250); }else{ myservo2.write(90); } }
I think the most challenging thing in this exercise is that if the condition of if statement is satisfied and the servo motor would be triggered immediately and would return to the original state as long as the if statement is not satisfied, the servo motor could actually move just a little bit. So the way to figure this out is to use a delay function.
In this exercise, I think there is actually no interaction. Because users only see the servo motor moves and the ball bounces. They could actually do nothing and thus there’s no exercise.
Additional
<still working>
Leave a Reply