interactivebody workshop_002_01=arduino_sensor
DESCRIPTION
[Technical Study]: For developing basic kinetic or interactive design projects, participants will need to learn basic interactive techniques from simulation to physical computing. Arduino, a well-known microcontroller, will be heavily experimented in this workshop. During the workshop, participants will get the general idea about the basic electronic engineering knowledge and how to use micro-controllers and embed sensing and actuation systems to build the physical prototype. However, they can start experiment the kinetic mechanism by studying physical model as well as virtual simulation through 3D modeling software (Rhino, Maya, Grasshopper...etc). The idea of cellular component and self-organized logics should lead the final projects to an emergent morphological body via collective decision making. Laser-cutting as a digital fabrication technique will also be utilized under the constraint of "using sheet material" for producing the physical prototypes.TRANSCRIPT
![Page 1: InteractiveBody Workshop_002_01=Arduino_Sensor](https://reader034.vdocuments.net/reader034/viewer/2022042719/568c0d641a28ab955a8c8d4a/html5/thumbnails/1.jpg)
ARDUINO(sensor)
![Page 2: InteractiveBody Workshop_002_01=Arduino_Sensor](https://reader034.vdocuments.net/reader034/viewer/2022042719/568c0d641a28ab955a8c8d4a/html5/thumbnails/2.jpg)
What is Sensor?
![Page 3: InteractiveBody Workshop_002_01=Arduino_Sensor](https://reader034.vdocuments.net/reader034/viewer/2022042719/568c0d641a28ab955a8c8d4a/html5/thumbnails/3.jpg)
It is Input!
![Page 4: InteractiveBody Workshop_002_01=Arduino_Sensor](https://reader034.vdocuments.net/reader034/viewer/2022042719/568c0d641a28ab955a8c8d4a/html5/thumbnails/4.jpg)
DigitalRead&Write
![Page 5: InteractiveBody Workshop_002_01=Arduino_Sensor](https://reader034.vdocuments.net/reader034/viewer/2022042719/568c0d641a28ab955a8c8d4a/html5/thumbnails/5.jpg)
Pressthebutton
![Page 6: InteractiveBody Workshop_002_01=Arduino_Sensor](https://reader034.vdocuments.net/reader034/viewer/2022042719/568c0d641a28ab955a8c8d4a/html5/thumbnails/6.jpg)
Signal
Upload the code: File > Examples > 2.Digital > Button.
Press
Light-on
release
Light-off
Press= connectGo the easiest way.
![Page 7: InteractiveBody Workshop_002_01=Arduino_Sensor](https://reader034.vdocuments.net/reader034/viewer/2022042719/568c0d641a28ab955a8c8d4a/html5/thumbnails/7.jpg)
/ constants won't change. They're used here to // set pin numbers:const int buttonPin = 2; // the number of the pushbutton pinconst int ledPin = 13; // the number of the LED pin
// variables will change:int buttonState = 0; // variable for reading the pushbutton status
void setup() {// initialize the LED pin as an output:pinMode(ledPin, OUTPUT); // initialize the pushbutton pin as an input:pinMode(buttonPin, INPUT);
}
void loop(){// read the state of the pushbutton value:buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.// if it is, the buttonState is HIGH:if (buttonState == HIGH) { // turn LED on: digitalWrite(ledPin, HIGH);
} else {// turn LED off:digitalWrite(ledPin, LOW);
}}
Set up which pin for what
If you press the button
It turns “on”
![Page 8: InteractiveBody Workshop_002_01=Arduino_Sensor](https://reader034.vdocuments.net/reader034/viewer/2022042719/568c0d641a28ab955a8c8d4a/html5/thumbnails/8.jpg)
AnalogRead
![Page 9: InteractiveBody Workshop_002_01=Arduino_Sensor](https://reader034.vdocuments.net/reader034/viewer/2022042719/568c0d641a28ab955a8c8d4a/html5/thumbnails/9.jpg)
potentiometer
![Page 10: InteractiveBody Workshop_002_01=Arduino_Sensor](https://reader034.vdocuments.net/reader034/viewer/2022042719/568c0d641a28ab955a8c8d4a/html5/thumbnails/10.jpg)
0-1024+ -
signal
![Page 11: InteractiveBody Workshop_002_01=Arduino_Sensor](https://reader034.vdocuments.net/reader034/viewer/2022042719/568c0d641a28ab955a8c8d4a/html5/thumbnails/11.jpg)
/*AnalogReadSerialReads an analog input on pin 0, prints the result to the serial monitor.Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
This example code is in the public domain.*/
// the setup routine runs once when you press reset:void setup() {// initialize serial communication at 9600 bits per second:Serial.begin(9600);
}
// the loop routine runs over and over again forever:void loop() {// read the input on analog pin 0:int sensorValue = analogRead(A0);// print out the value you read:Serial.println(sensorValue);delay(1); // delay in between reads for stability
}
Set up which pin for what
Read the message from Analog Pin0
In every ? million second
Print out the value
How to see it?
Upload the code: http://arduino.cc/en/Tutorial/AnalogReadSerial
![Page 12: InteractiveBody Workshop_002_01=Arduino_Sensor](https://reader034.vdocuments.net/reader034/viewer/2022042719/568c0d641a28ab955a8c8d4a/html5/thumbnails/12.jpg)
Serial Monitor
![Page 13: InteractiveBody Workshop_002_01=Arduino_Sensor](https://reader034.vdocuments.net/reader034/viewer/2022042719/568c0d641a28ab955a8c8d4a/html5/thumbnails/13.jpg)
Let’s have some fun=Connect to Processing
Upload the code: http://arduino.cc/en/Tutorial/AnalogReadSerial
![Page 14: InteractiveBody Workshop_002_01=Arduino_Sensor](https://reader034.vdocuments.net/reader034/viewer/2022042719/568c0d641a28ab955a8c8d4a/html5/thumbnails/14.jpg)
Same Code for “Arduino”
Upload the code: http://arduino.cc/en/Tutorial/AnalogReadSerial
![Page 15: InteractiveBody Workshop_002_01=Arduino_Sensor](https://reader034.vdocuments.net/reader034/viewer/2022042719/568c0d641a28ab955a8c8d4a/html5/thumbnails/15.jpg)
/*AnalogReadSerialReads an analog input on pin 0, prints the result to the serial monitor.Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
This example code is in the public domain.*/
// the setup routine runs once when you press reset:void setup() {// initialize serial communication at 9600 bits per second:Serial.begin(9600);
}
// the loop routine runs over and over again forever:void loop() {// read the input on analog pin 0:int sensorValue = analogRead(A0);// print out the value you read:Serial.println(sensorValue);delay(1); // delay in between reads for stability
}
Set up which pin for what
Read the message from Analog Pin0
In every ? million second
Print out the value
How to see it?
![Page 16: InteractiveBody Workshop_002_01=Arduino_Sensor](https://reader034.vdocuments.net/reader034/viewer/2022042719/568c0d641a28ab955a8c8d4a/html5/thumbnails/16.jpg)
Code for “Processing”
Upload the code: http://arduino.cc/en/Tutorial/Graph
![Page 17: InteractiveBody Workshop_002_01=Arduino_Sensor](https://reader034.vdocuments.net/reader034/viewer/2022042719/568c0d641a28ab955a8c8d4a/html5/thumbnails/17.jpg)
import processing.serial.*;Serial myPort; // The serial portint xPos = 1; // horizontal position of the graph
void setup () {// set the window size:size(1000, 500); // List all the available serial portsprintln(Serial.list());// I know that the first port in the serial list on my mac // is always my Arduino, so I open Serial.list()[0].// Open whatever port is the one you're using.myPort = new Serial(this, Serial.list()[0], 9600);myPort.bufferUntil('\n'); // don't generate a serialEvent() unless you get a newline character:background(0); // set inital background:}void draw () { // everything happens in the serialEvent()}
void serialEvent (Serial myPort) {// get the ASCII string:String inString = myPort.readStringUntil('\n');
if (inString != null) {// trim off any whitespace:inString = trim(inString);// convert to an int and map to the screen height:float inByte = float(inString); inByte = map(inByte, 0, 1023, 0, height);// draw the line:stroke(127,34,255);line(xPos, height, xPos, height - inByte);// at the edge of the screen, go back to the beginning:
if (xPos >= width) {xPos = 0;background(0); }
else {// increment the horizontal position:xPos++; }
}}
Import the library
Check the serial
Break the numbers
Where we can play with
Remap the Value
![Page 18: InteractiveBody Workshop_002_01=Arduino_Sensor](https://reader034.vdocuments.net/reader034/viewer/2022042719/568c0d641a28ab955a8c8d4a/html5/thumbnails/18.jpg)
![Page 19: InteractiveBody Workshop_002_01=Arduino_Sensor](https://reader034.vdocuments.net/reader034/viewer/2022042719/568c0d641a28ab955a8c8d4a/html5/thumbnails/19.jpg)
LDRLight Dependent Resistor
![Page 20: InteractiveBody Workshop_002_01=Arduino_Sensor](https://reader034.vdocuments.net/reader034/viewer/2022042719/568c0d641a28ab955a8c8d4a/html5/thumbnails/20.jpg)
/*AnalogReadSerialReads an analog input on pin 0, prints the result to the serial monitor.Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
This example code is in the public domain.*/
// the setup routine runs once when you press reset:void setup() {// initialize serial communication at 9600 bits per second:Serial.begin(9600);
}
// the loop routine runs over and over again forever:void loop() {// read the input on analog pin 0:int sensorValue = analogRead(A0);// print out the value you read:Serial.println(sensorValue);delay(1); // delay in between reads for stability
}
Set up which pin for what
Read the message from Analog Pin0
In every ? million second
Print out the value
Turn on your serial monitor
Same code from: http://arduino.cc/en/Tutorial/AnalogReadSerial
![Page 21: InteractiveBody Workshop_002_01=Arduino_Sensor](https://reader034.vdocuments.net/reader034/viewer/2022042719/568c0d641a28ab955a8c8d4a/html5/thumbnails/21.jpg)
LDR
![Page 22: InteractiveBody Workshop_002_01=Arduino_Sensor](https://reader034.vdocuments.net/reader034/viewer/2022042719/568c0d641a28ab955a8c8d4a/html5/thumbnails/22.jpg)
import processing.serial.*;Serial myPort; // The serial portint xPos = 1; // horizontal position of the graph
void setup () {// set the window size:size(1000, 500); // List all the available serial portsprintln(Serial.list());// I know that the first port in the serial list on my mac // is always my Arduino, so I open Serial.list()[0].// Open whatever port is the one you're using.myPort = new Serial(this, Serial.list()[0], 9600);myPort.bufferUntil('\n'); // don't generate a serialEvent() unless you get a newline character:background(0); // set inital background:}void draw () { // everything happens in the serialEvent()}
void serialEvent (Serial myPort) {// get the ASCII string:String inString = myPort.readStringUntil('\n');
if (inString != null) {// trim off any whitespace:inString = trim(inString);// convert to an int and map to the screen height:float inByte = float(inString); inByte = map(inByte, 0, 100, 0, height);// draw the line:stroke(127,34,255);line(xPos, height, xPos, height - inByte);// at the edge of the screen, go back to the beginning:
if (xPos >= width) {xPos = 0;background(0); }
else {// increment the horizontal position:xPos++; }
}}
Still you can play with Processing(Same Code)
Check the serial
Break the numbers
Where we can play with
Need to Remap this
![Page 23: InteractiveBody Workshop_002_01=Arduino_Sensor](https://reader034.vdocuments.net/reader034/viewer/2022042719/568c0d641a28ab955a8c8d4a/html5/thumbnails/23.jpg)
![Page 24: InteractiveBody Workshop_002_01=Arduino_Sensor](https://reader034.vdocuments.net/reader034/viewer/2022042719/568c0d641a28ab955a8c8d4a/html5/thumbnails/24.jpg)
Some Examples I did
https://vimeo.com/14201235
![Page 25: InteractiveBody Workshop_002_01=Arduino_Sensor](https://reader034.vdocuments.net/reader034/viewer/2022042719/568c0d641a28ab955a8c8d4a/html5/thumbnails/25.jpg)
https://vimeo.com/14201235
![Page 26: InteractiveBody Workshop_002_01=Arduino_Sensor](https://reader034.vdocuments.net/reader034/viewer/2022042719/568c0d641a28ab955a8c8d4a/html5/thumbnails/26.jpg)
![Page 27: InteractiveBody Workshop_002_01=Arduino_Sensor](https://reader034.vdocuments.net/reader034/viewer/2022042719/568c0d641a28ab955a8c8d4a/html5/thumbnails/27.jpg)
https://vimeo.com/13977345
![Page 28: InteractiveBody Workshop_002_01=Arduino_Sensor](https://reader034.vdocuments.net/reader034/viewer/2022042719/568c0d641a28ab955a8c8d4a/html5/thumbnails/28.jpg)
https://vimeo.com/13977625
![Page 29: InteractiveBody Workshop_002_01=Arduino_Sensor](https://reader034.vdocuments.net/reader034/viewer/2022042719/568c0d641a28ab955a8c8d4a/html5/thumbnails/29.jpg)
Did you get the idea?
![Page 30: InteractiveBody Workshop_002_01=Arduino_Sensor](https://reader034.vdocuments.net/reader034/viewer/2022042719/568c0d641a28ab955a8c8d4a/html5/thumbnails/30.jpg)
It’s all about INPUT
& OUTPUT