Commit 874d7170 authored by Dorota Orlof's avatar Dorota Orlof
Browse files

adding final project files

parent bf0ddd49
Pipeline #30900 passed with stages
in 39 seconds
......@@ -137,11 +137,14 @@ I'm assembling magnet-holders from lasercutted pieces.
And fixing them on the board.
-----
**Holders for the back-boad**
I've also designed holding system for fixing the board on the wall. There are two holders which are going to be screwed to the wall. The back-board can be easily slide in in between them from the side.
-----
![fin](../images/fin_3Dholders.jpg)
![fin](../images/fin_3Dholders_2.jpg)
**Electronics**
......@@ -149,43 +152,310 @@ Since my capacitance sensor board (manufactured in [Input Devices week](http://f
![fin](../images/fin_soldering.jpg)
I'm going to connect four vibration motors to the board that I've created during [Output Devices week](http://fab.academany.org/2018/labs/barcelona/students/dorota-orlof/assignments/assignment11/)) On my board I've left a place for the battery to power the motors, but it appeared that they are all working with 5Volts from FTDI cable! That's coolsince the sensor will be lighter without the battery.
The flow will be as follows:
**Sensor will send a signal through serial communication, this will activate the Processing animation running on RaspberryPi as well as the vibration motors.**
Assambly
![fin](../images/fin_board_3.jpg)
-----
**Programming**
**Assemblage**
I'm going to re-do the Arduino code that I've written during the [Networking and Communication week](http://fab.academany.org/2018/labs/barcelona/students/dorota-orlof/assignments/assignment13/)
All together the sensor is assembled from two parts.
From the other end I'm goingto modify the Processing code that I've created during the [Interface and application programming week](http://fab.academany.org/2018/labs/barcelona/students/dorota-orlof/assignments/assignment12/).
The flow will be as follows:
![fin](../images/fin_all_2.jpg)
**Sensor will send a signal through serial communication, this will activate the Processing animation running on RaspberryPi as well as the vibration motors.**
![fin](../images/fin_all_4.jpg)
![fin](../images/fin_all_1.jpg)
I've fixed the floating felt pieces with pins - they have perfect length for the thickness of a board.
![fin](../images/fin_all_3.jpg)
Assemblage with all the cabling. In this case I've put the battery as a placeholder (it appeared that it's not necessary)
![fin](../images/fin_all.jpg)
-----
![fin](../images/fin_board_1.jpg)
**Programming**
First I'm testing if Sensor is reading the data according to the plan. I'm opening the Serial Monitor and touching sensing pin.
I'm going to re-do the Arduino code for Capacitance Sensor that I've written during the [Networking and Communication week](http://fab.academany.org/2018/labs/barcelona/students/dorota-orlof/assignments/assignment13/)
[Kris](http://fab.academany.org/2018/labs/barcelona/students/krisjanis-rijnieks/) gave me tipps how to get more stabile results. To reach that I'm going to use `long capacitiveSensor(byte samples)` method. Detailed description one can find on [Capacitive Sensing Library](https://playground.arduino.cc/Main/CapacitiveSensor?from=Main.CapSense) page by Arduino.
```
#include <SoftwareSerial.h>
#include <CapacitiveSensor.h>
#define NUM_SAMPLES 30
#define THRESHOLD 5000
SoftwareSerial myComCat(8, 4);
SoftwareSerial myComDog(5, 6);
CapacitiveSensor cs_2_3 = CapacitiveSensor(2, 3);
unsigned long average = 0;
unsigned long threshold = THRESHOLD;
unsigned long samples[NUM_SAMPLES];
int currSample = 0;
int maxSamples = NUM_SAMPLES;
void setup() {
myComCat.begin(9600);
myComDog.begin(9600);
}
void loop(){
myComCat.listen();
while (myComCat.available() > 0) {
char inByte = myComCat.read();
myComDog.write(inByte);
}
delay(100);
unsigned long reading = cs_2_3.capacitiveSensor(30);
if(currSample < maxSamples){
```
In the beginning we have to read the first NUM_SAMPLES samples since the array is empty.
```
samples[currSample] = reading;
currSample++;
myComCat.println("sampling...");
}else{
```
When we are done reading in the NUM_SAMPLES readings we have an array we can use for averaging. We have to shift all readings of an array. We have to drop the first one and add one on top so that we still have only NUM_SAMPLES readings.
Remove one sample from the beginning and add one sample at the end of the array:
```
for(int i = 0; i < maxSamples; i++){
if(i < maxSamples - 1){
samples[i] = samples[i+1];
}else{
samples[i] = reading;
}
}
unsigned long sum = 0;
for(int i = 0; i < maxSamples; i++){
sum += samples[i];
}
unsigned long numSamples = NUM_SAMPLES;
average = sum / numSamples;
myComCat.print("sum: ");
myComCat.print(sum);
myComCat.print("\t");
myComCat.print("average: ");
myComCat.print(average);
myComCat.print("\t");
myComCat.print("reading: ");
myComCat.println(reading);
if (reading > average + threshold) {
myComCat.println("Fingers move!");
myComDog.write('1');
}
}
}
```
I'm connecting the furry sensor to the board and testing if the data are being red according to the plan.
<iframe width="560" height="315" src="https://www.youtube.com/embed/cgtR2Q2zzDM?rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
I'm transfering thefiles to RaspberryPi and testing the animation. Looks like after days of tries it's finally working!
-----
For **output board** I'm using the same code that I've used for the [Networking and Communication Assignment](http://fab.academany.org/2018/labs/barcelona/students/dorota-orlof/assignments/assignment13/).
```
#include <SoftwareSerial.h>
const int vibPin = 1;
unsigned long previousMillis = 0;
unsigned long interval = 2000;
```
Since we use the port for listening only (on RX, which is 0) It is ok, that the TX pin is the same as vibPin.
```
SoftwareSerial inputPort(0, 1);
void setup() {
pinMode(vibPin, OUTPUT);
inputPort.begin(9600);
previousMillis = millis();
}
void loop() {
```
Move the DC Motor
```
unsigned long currentMillis = millis();
unsigned long timePassed = currentMillis - previousMillis;
if (timePassed > interval) {
digitalWrite(vibPin, LOW);
}else{
digitalWrite(vibPin, HIGH);
}
while (inputPort.available() > 0) {
char inByte = inputPort.read();
```
Addressing: When we receive 1, we spin the motor
```
if (inByte == '1') {
previousMillis = currentMillis;
}
}
}
```
<iframe width="560" height="315" src="https://www.youtube.com/embed/XfGhhRS-j44?rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
____
From the other end I'm going to modify the **Processing code** that I've created during the [Interface and application programming week](http://fab.academany.org/2018/labs/barcelona/students/dorota-orlof/assignments/assignment12/). This time I'm going to run an animation by displaying four pngs one after another.
```
import processing.serial.*; //import the Serial library
Serial doraPort; //the Serial port object
String val;
Animation animation1, animation2;
float xpos;
float ypos;
float drag = 30.0;
boolean firstContact = false;
void setup() {
fullScreen();
background(0);
frameRate(24);
animation1 = new Animation("anim_", 1);
animation2 = new Animation("anim_", 4);
ypos = height * 0.25;
doraPort = new Serial(this, Serial.list()[1], 9600);
doraPort.bufferUntil('\n');
}
void draw() {
animation2.display(0, 0);
}
void serialEvent( Serial myPort ) {
```
put the incoming data into a String - the '\n' is our end delimiter indicating the end of a complete packet
```
val = myPort.readStringUntil('\n');
```
make sure our data isn't empty before continuing
```
if (val != null) {
```
trim whitespace and formatting characters (like carriage return)
```
val = trim(val);
println(val);
}else if(val.equals("high")){
animation2.display(0, 0);
} else {
animation1.display(0, 0);
}
}
class Animation {
PImage[] images;
int imageCount;
int frame;
Animation(String imagePrefix, int count) {
imageCount = count;
images = new PImage[imageCount];
for (int i = 0; i < imageCount; i++) {
```
Use nf() to number format 'i' into four digits
```
String filename = imagePrefix + nf(i, 2) + ".gif";
images[i] = loadImage(filename);
}
}
void display(float xpos, float ypos) {
frame = (frame+1) % imageCount;
image(images[frame], xpos, ypos);
delay(100);
}
int getWidth() {
return images[0].width;
}
}
```
<iframe width="560" height="315" src="https://www.youtube.com/embed/phaRVt-hXxc?rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
-----
**Projection mapping**
I'm transfering the files to RaspberryPi and testing the animation. It's finally waving to me.
<iframe width="560" height="315" src="https://www.youtube.com/embed/PuJYakFwavs?rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/S31rAPwA8uA?rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/TFMnnCCZ-YE?rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
Assamblage
After setting up everything in the proper settings the animated hand is ready to be tickled!
![fin](../images/fin_all.jpg)
<iframe width="560" height="315" src="https://www.youtube.com/embed/TFMnnCCZ-YE?rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
----
*Files made during this assignment:*
Circular board
Hairy unit / laser
hairy unit / for janome
Magnet holders
Motor holders
3D printed holders for a wall
Code Capacitance Sensor
Code Moto Output
Code Processing
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
This diff is collapsed.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
This diff is collapsed.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
This diff is collapsed.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
This diff is collapsed.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment