-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
ambient7-arduino/arduino-ide-version/ambient7-mcu/ambient7-mcu.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include <SoftwareSerial.h> | ||
|
||
unsigned long startTime = millis(); | ||
|
||
void setup() { | ||
Serial.begin(9600); | ||
pinMode(D3, INPUT); | ||
} | ||
|
||
void loop() { | ||
Serial.println("------------------------------"); | ||
Serial.print("Time from start: "); | ||
Serial.print((millis() - startTime) / 1000); | ||
Serial.println(" s"); | ||
int ppm_pwm = readCO2PWM(); | ||
delay(5000); | ||
} | ||
|
||
int readCO2PWM() { | ||
unsigned long th, tl, ppm_pwm = 0; | ||
do { | ||
th = pulseIn(D3, HIGH, 1004000) / 1000; | ||
Serial.println("Step"); | ||
tl = 1004 - th; | ||
ppm_pwm = 5000 * (th-2)/(th+tl-4); | ||
} while (th == 0); | ||
Serial.print("PPM PWM: "); | ||
Serial.println(ppm_pwm); | ||
return ppm_pwm; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include <SoftwareSerial.h> | ||
|
||
unsigned long startTime = millis(); | ||
|
||
void setup() { | ||
Serial.begin(9600); | ||
co2Serial.begin(9600); | ||
pinMode(D3, INPUT); | ||
} | ||
|
||
void loop() { | ||
Serial.println("------------------------------"); | ||
Serial.print("Time from start: "); | ||
Serial.print((millis() - startTime) / 1000); | ||
Serial.println(" s"); | ||
int ppm_pwm = readCO2PWM(); | ||
delay(5000); | ||
} | ||
|
||
int readCO2PWM() { | ||
unsigned long th, tl, ppm_pwm = 0; | ||
do { | ||
th = pulseIn(D3, HIGH, 1004000) / 1000; | ||
tl = 1004 - th; | ||
ppm_pwm = 5000 * (th-2)/(th+tl-4); | ||
} while (th == 0); | ||
Serial.print("PPM PWM: "); | ||
Serial.println(ppm_pwm); | ||
return ppm_pwm; | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.