~alienagain/future_wear

4154e02e09fd938546d6801f9e762eafffd3838f — paula 2 months ago
art research on electronic scuptures and fictional narratives
5 files changed, 157 insertions(+), 0 deletions(-)

A LICENSE
A README.md
A letsbreathtogether/sensor.ino
A letsbreathtogether/servo.ino
A letsbreathtogether/todo.ino
A  => LICENSE +2 -0
@@ 1,2 @@
#todo


A  => README.md +1 -0
@@ 1,1 @@
# TODO

A  => letsbreathtogether/sensor.ino +63 -0
@@ 1,63 @@
/*

 Interfacing Sharp Optical Dust Sensor GP2Y1014AU0F with Arduino

*/

int measurePin = 0; //Connect dust sensor to Arduino A0 pin

//#define ledPower = 7;   //Connect 3 led driver pins of dust sensor to Arduino D2

int samplingTime = 280; // time required to sample signal coming out   of the sensor

int deltaTime = 40; // 

int sleepTime = 9680;

float voMeasured = 0;

float calcVoltage = 0;

float dustDensity = 0;

void setup(){

  Serial.begin(9600);

//  pinMode(ledPower,OUTPUT);

}

void loop(){

//  digitalWrite(ledPower,LOW); // power on the LED

  delayMicroseconds(samplingTime);

  voMeasured = analogRead(measurePin); // read the dust value

  delayMicroseconds(deltaTime);

//  digitalWrite(ledPower,HIGH); // turn the LED off

  delayMicroseconds(sleepTime);

  // 0 - 5V mapped to 0 - 1023 integer values

  // recover voltage

  calcVoltage = voMeasured * (5.0 / 1024.0);

  // linear eqaution taken from http://www.howmuchsnow.com/arduino/airquality/

  // Chris Nafis (c) 2012

  dustDensity = 170 * calcVoltage - 0.1;

  Serial.println(dustDensity); // unit: ug/m3

  delay(1000);

}



A  => letsbreathtogether/servo.ino +29 -0
@@ 1,29 @@
/*
 * Created by ArduinoGetStarted.com
 *
 * This example code is in the public domain
 *
 * Tutorial page: https://arduinogetstarted.com/tutorials/arduino-servo-motor
 */

#include <Servo.h>

Servo servo;  // create servo object to control a servo

void setup() {
  servo.attach(9);  // attaches the servo on pin 9 to the servo objectÆ°
  servo.write(0);   // rotate slowly servo to 0 degrees immediately
}

void loop() {
  for (int pos = 0; pos <= 180; pos += 1) {  // rotate slowly from 0 degrees to 180 degrees, one by one degree
    // in steps of 1 degree
    servo.write(pos);  // control servo to go to position in variable 'pos'
    delay(10);         // waits 10ms for the servo to reach the position
  }

  for (int pos = 180; pos >= 0; pos -= 1) {  // rotate from 180 degrees to 0 degrees, one by one degree
    servo.write(pos);                        // control servo to go to position in variable 'pos'
    delay(10);                               // waits 10ms for the servo to reach the position
  }
}

A  => letsbreathtogether/todo.ino +62 -0
@@ 1,62 @@
/*
 * Created by ArduinoGetStarted.com
 *
 * This example code is in the public domain
 *
 * Tutorial page: https://arduinogetstarted.com/tutorials/arduino-servo-motor
 */

#include <Servo.h>

Servo servo;  // create servo object to control a servo

int measurePin = 0; //Connect dust sensor to Arduino A0 pin

//#define ledPower = 7;   //Connect 3 led driver pins of dust sensor to Arduino D2

int samplingTime = 280; // time required to sample signal coming out   of the sensor

int deltaTime = 40; // 

int sleepTime = 9680;

float voMeasured = 0;

float calcVoltage = 0;

float dustDensity = 0;



void setup() {
  Serial.begin(9600);
  servo.attach(9);  // attaches the servo on pin 9 to the servo objectÆ°
  servo.write(0);   // rotate slowly servo to 0 degrees immediately
}

void loop() {
  //sensor
  delayMicroseconds(samplingTime);
  voMeasured = analogRead(measurePin); // leer el valor del sensor
  delayMicroseconds(deltaTime);
  delayMicroseconds(sleepTime);

  calcVoltage = voMeasured * (5.0 / 1024.0);
  dustDensity = 170 * calcVoltage - 0.1;
  Serial.println(dustDensity); // unit: ug/m3
  // una vez leo esto, determino:
  
  for (int pos = 0; pos <= 180; pos += 1) {  // rotate slowly from 0 degrees to 180 degrees, one by one degree
    // in steps of 1 degree
    servo.write(pos);  // control servo to go to position in variable 'pos'
    delay(10);         // waits 10ms for the servo to reach the position
  }

  for (int pos = 180; pos >= 0; pos -= 1) {  // rotate from 180 degrees to 0 degrees, one by one degree
    servo.write(pos);                        // control servo to go to position in variable 'pos'
    delay(10);                               // waits 10ms for the servo to reach the position
  }
}


// mejoras: paralelismo