int strip_detect = 2;
int current = 0;
float threshold = 2.8;
#include <Wire.h>
#include "RTClib.h"
RTC_Millis RTC;
void setup() {
Serial.begin(9600);
RTC.begin(DateTime(__DATE__, __TIME__));
pinMode(strip_detect, INPUT);
}
void loop() {
while(1) {
if(digitalRead(strip_detect) == 1) break;
}
Serial.println("APPLY BLOOD");
float current_voltage;
while(1) {
current_voltage = analogRead(0) * (5.0 / 1023.0);
if(current_voltage > threshold) break;
}
for(int i = 5; i > 0; i--) {
delay(1000);
Serial.print(i);
if(i > 1) Serial.print(", ");
else Serial.println("");
}
current_voltage = analogRead(0) * (5.0 / 1023.0);
float concentration = 495.6 * current_voltage - 1275.5;
Serial.print(concentration);
Serial.println(" mg/dL");
display_time();
while(1) {
if(digitalRead(strip_detect) == 0) break;
}
delay(1000);
}
void display_time() {
DateTime now = RTC.now();
Serial.print(now.year(), DEC);
Serial.print('-');
Serial.print(now.month(), DEC);
Serial.print('-');
Serial.print(now.day(), DEC);
Serial.print(' ');
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
}
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.
Looking great.
Are you sure? yes | no