Dealing with Diabetes: The Road to Developing an Artificial Pancreas
Posted: Thu Nov 23, 2023 10:46 am
Hi,
I created the artificial pancreas model using the 100K ohm resistor. It was successful but it overshot the threshold value, so I am trying to use a potentiometer, but it doesn't work. I don't know if my connectivity and code is correct, and I have attached my code and the circuit diagram to this post. Can someone please verify and let me know?
Thank you for your help,
Kavk
Code:
// declare variables for pins
const int pump_pin = 11;
const int potpin = A0;
int conductivity;
int speed;
int threshold = 100;
void setup() {
// put your setup code here, to run once:
pinMode(pump_pin,OUTPUT); // set pump pin as output
Serial.begin(9600); // initialize serial communication
}
void loop () { // code that loops forever
conductivity = analogRead (A0);
Serial.println(conductivity);
speed = map (conductivity,0,1023,0,255);
if(conductivity>threshold){
analogWrite(pump_pin,speed); // turn pump on if threshold has not been reached yet
}
else{
digitalWrite(pump_pin,LOW); // turn pump off if threshold has been reached
}
}
I created the artificial pancreas model using the 100K ohm resistor. It was successful but it overshot the threshold value, so I am trying to use a potentiometer, but it doesn't work. I don't know if my connectivity and code is correct, and I have attached my code and the circuit diagram to this post. Can someone please verify and let me know?
Thank you for your help,
Kavk
Code:
// declare variables for pins
const int pump_pin = 11;
const int potpin = A0;
int conductivity;
int speed;
int threshold = 100;
void setup() {
// put your setup code here, to run once:
pinMode(pump_pin,OUTPUT); // set pump pin as output
Serial.begin(9600); // initialize serial communication
}
void loop () { // code that loops forever
conductivity = analogRead (A0);
Serial.println(conductivity);
speed = map (conductivity,0,1023,0,255);
if(conductivity>threshold){
analogWrite(pump_pin,speed); // turn pump on if threshold has not been reached yet
}
else{
digitalWrite(pump_pin,LOW); // turn pump off if threshold has been reached
}
}