17.08.2020 Views

AirQfy Fear Not the Particulates

An IoT group project

An IoT group project

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

int led_onboard = 13;

int threshold_mindist = 80; // minimum distance for sensor to detect object [cm]

long duration_pink, duration_yellow, distance_cm_pink, distance_cm_yellow;

void setup() {

//Serial Port begin

Serial.begin (9600);

//Define inputs and outputs

pinMode(trigPin_orange, OUTPUT);

pinMode(echoPin_yellow, INPUT);

pinMode(trigPin_purple, OUTPUT);

pinMode(echoPin_pink, INPUT);

pinMode(led_onboard, OUTPUT);

digitalWrite(led_onboard, LOW);

}

void loop() {

// Sensor Orange/Yellow: ///////////////////////////////////////////

// The sensor is triggered by a HIGH pulse of 10 or more microseconds.

// Give a short LOW pulse beforehand to ensure a clean HIGH pulse:

digitalWrite(trigPin_orange, LOW);

delayMicroseconds(5);

digitalWrite(trigPin_orange, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin_orange, LOW);

// Read the signal from the sensor: a HIGH pulse whose

// duration is the time (in microseconds) from the sending

// of the ping to the reception of its echo off of an object.

duration_yellow = pulseIn(echoPin_yellow, HIGH);

distance_cm_yellow = (duration_yellow / 2) / 29.1; // Divide by 29.1 or multiply by 0.0343

// Sensor Purple/Pink: ///////////////////////////////////////////

digitalWrite(trigPin_purple, LOW);

delayMicroseconds(5);

digitalWrite(trigPin_purple, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin_purple, LOW);

duration_pink = pulseIn(echoPin_pink, HIGH);

distance_cm_pink = (duration_pink / 2) / 29.1; // Divide by 29.1 or multiply by 0.0343

// Serial.print(distance_cm_yellow);

// Serial.println("cm (Gate 2)");

// Serial.print(distance_cm_pink);

// Serial.println("cm (Gate 1)");

31

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!