<commit_before>/*
  MiCS-VZ-86 to read PPM
 Sample every 5 seconds
 
 This example code is in the public domain.
 
 modified 21 Jan 2015
 by <NAME>
 */

#define PWM_PIN 3

volatile unsigned long pwm_value = 0;
volatile unsigned long pwm_co2 = 0;
volatile unsigned long pwm_voc = 0;
volatile unsigned long prev_time = 0;

boolean channel = false;

// the setup function runs once when you press reset or power the board
void setup() {
  Serial.begin(115200);
  delay(5000);
  attachInterrupt(1, rising, RISING);
}

// the loop function runs over and over again forever
void loop() {
  delay(1000);
  
  Serial.print("CO2: ");
  Serial.println((pwm_co2>pwm_voc?pwm_co2:pwm_voc));
  Serial.print("VOC: ");
  Serial.println((pwm_voc<pwm_co2?pwm_voc:pwm_co2));
}

void falling() {
  pwm_value = (millis() - prev_time)*3;
  if( !channel ){
    pwm_co2 = pwm_value;
  } 
  else {
    pwm_voc = pwm_value;
  }
   channel = !channel; 
  attachInterrupt(1, rising, RISING);
}

void rising(){
  prev_time = millis();
  attachInterrupt(1, falling, FALLING);
}

<commit_msg>output CO2 in ppm, VOC in ppb<commit_after>/*
  MiCS-VZ-86 to read PPM
 Sample every 5 seconds
 
 This example code is in the public domain.
 
 modified 21 Jan 2015
 by <NAME>
 */

#define PWM_PIN 3

volatile unsigned long pwm_value = 0;
volatile unsigned long pwm_value1 = 0;
volatile unsigned long pwm_value2 = 0;
volatile unsigned long prev_time = 0;
int pwm_co2 = 0;
int pwm_voc = 0;

boolean channel = false;
unsigned long tmp;

// the setup function runs once when you press reset or power the board
void setup() {
  Serial.begin(115200);
  delay(5000);
  attachInterrupt(1, rising, RISING);
}

// the loop function runs over and over again forever
void loop() {
  delay(1000);
  
  // make sure pwm_value 1 > pwm_value2
  if( pwm_value1 < pwm_value2 )
  {
    tmp = pwm_value1;
    pwm_value1 = pwm_value2;
    pwm_value2 = tmp;
  }
  pwm_co2 = 40*pwm_value1-1800;
  pwm_voc = 25*pwm_value2-125;
    
  //Serial.print(pwm_value1);
  //Serial.print(" ");
  //Serial.println(pwm_value2);
  Serial.print("CO2: ");
  Serial.println(pwm_co2);
  Serial.print("VOC: ");
  Serial.println(pwm_voc);
}

void falling() {
  pwm_value = (millis() - prev_time)*3;
  if( !channel ){
    pwm_value1 = pwm_value;
  } 
  else {
    pwm_value2 = pwm_value;
  }
   channel = !channel; 
  attachInterrupt(1, rising, RISING);
}

void rising(){
  prev_time = millis();
  attachInterrupt(1, falling, FALLING);
}


{'fraction_non_alphanumeric': 0.11803011803011804, 'fraction_numerical': 0.042735042735042736, 'mean_word_length': 3.594392523364486, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6317788', 'n_tokens_mistral': 1003, 'n_tokens_neox': 922, 'n_words': 254}