Dealing with Diabetes: The Road to Developing an Artificial Pancreas

Ask questions about projects relating to: biology, biochemistry, genomics, microbiology, molecular biology, pharmacology/toxicology, zoology, human behavior, archeology, anthropology, political science, sociology, geology, environmental science, oceanography, seismology, weather, or atmosphere.

Moderators: AmyCowen, kgudger, bfinio, MadelineB, Moderators

Post Reply
kavk
Posts: 2
Joined: Tue Oct 24, 2023 6:09 pm
Occupation: Student

Dealing with Diabetes: The Road to Developing an Artificial Pancreas

Post by kavk »

potcircuit.pdf
potentiometer connection
(272.84 KiB) Downloaded 309 times
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
}
}


pancreascircuit.pdf
full model circuit
(4.31 MiB) Downloaded 306 times
potcircuit.pdf
potentiometer connection
(272.84 KiB) Downloaded 309 times
petroben
Posts: 2
Joined: Thu Nov 23, 2023 11:22 pm
Occupation: Student

Re: Dealing with Diabetes: The Road to Developing an Artificial Pancreas

Post by petroben »

Hi Kavk,

It's great that you've been working on your artificial pancreas model. I'll do my best to help you with the code and circuit.

Looking at your code, here are a few things to consider:

Ensure that your potentiometer is wired correctly. The middle pin should be connected to A0, and the other two pins should be connected to 5V and GND.

Double-check your threshold value. If it's overshooting, you might need to adjust the threshold to a lower value.

Consider adding a delay in your loop to avoid reading the analog value too quickly. You can use delay(100) to add a 100-millisecond delay.

Ensure that your pump is functioning correctly and is connected to the correct pin (pin 11).

Monitor the serial output to get a better understanding of the conductivity values and whether they match your expectations.

If you provide more details about the issues you're facing, I can offer more specific guidance. Additionally, if you have a circuit diagram, please share it so I can review the connections.

Best of luck with your project!
kavk
Posts: 2
Joined: Tue Oct 24, 2023 6:09 pm
Occupation: Student

Re: Dealing with Diabetes: The Road to Developing an Artificial Pancreas

Post by kavk »

Hi Petroben,
Thanks for the response.
I removed the 100k ohm resistor and replaced it with a 10k ohm potentiometer. I am wondering if that is why the motor isn't running. What value potentiometer does this require? Should I use a greater valued potentiometer instead? I have also attached a circuit diagram.
Thank you

artificial pancreas circuit.pdf
(166.29 KiB) Downloaded 306 times
SujinLee
Posts: 5
Joined: Tue Nov 14, 2023 6:30 am
Occupation: Student

Re: Dealing with Diabetes: The Road to Developing an Artificial Pancreas

Post by SujinLee »

Using a potentiometer to fine-tune the threshold value is a good idea. First, ensure that the potentiometer is correctly connected to the A0 pin, and check for any loose connections. You can also test the potentiometer's functionality by reading its values with analogRead(potpin) and printing them to Serial. If everything looks fine but it still doesn't work as expected, consider calibrating the threshold value based on the potentiometer readings.
Post Reply

Return to “Grades 6-8: Life, Earth, and Social Sciences”