Arduino programming based on the information for each fruits to determine glycemic index range.
Fruits | Range |
Watermelon | 72 (+-) 3 |
Orange | 42 (+-) 3 |
Apple | 38 (+-)2 |
Mango | 56 (+-)2 |
Pepsi | 55 (+-)3 |
LOW < 55 , MEDIUM 56-69 , HIGH > 70
ARDUINO PROGRAMMING :
// set pin numbers:
const int sw1 = 6; // the number of the pushbutton pin1
const int sw2 = 7; // the number of the pushbutton pin2
const int sw3 = 8; // the number of the pushbutton pin3
const int sw4 = 9; // the number of the pushbutton pin4
const int sw5 = 10; // the number of the pushbutton pin5
const int buzzer = 1; // the number of the Buzzer pin
int sensorPin = A0; // select the input pin for the potentiometer
int sensorValue = 0; // variable to store the value coming from the sensor
int mode = 0;
// include the library code:
#include
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void show_low()
{
lcd.setCursor(12,1);
lcd.print("Low ");
}
void show_med()
{
lcd.setCursor(12,1);
lcd.print("Med ");
}
void show_high()
{
lcd.setCursor(12,1);
lcd.print("High");
}
void setup() {
pinMode(sw1, INPUT);
pinMode(sw2, INPUT);
pinMode(sw3, INPUT);
pinMode(sw4, INPUT);
pinMode(sw5, INPUT);
pinMode(buzzer,OUTPUT);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Sugar Detector!");
digitalWrite(buzzer,HIGH);
delay(1000);
digitalWrite(buzzer,LOW);
}
void loop() {
if(digitalRead(sw1)==1)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("WaterMelon");
mode=1;
}
if(digitalRead(sw2)==1)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Orange");
mode=2;
}
if(digitalRead(sw3)==1)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Apple");
mode=3;
}
if(digitalRead(sw4)==1)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Mango");
mode=4;
}
if(digitalRead(sw5)==1)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Carbonate Drink");
mode=5;
}
sensorValue = analogRead(sensorPin);
sensorValue = sensorValue/6.5;
lcd.setCursor(0,1);
lcd.print("Value: ");
lcd.setCursor(6,1);
lcd.print(sensorValue,DEC);
if(mode==1)
{
if(sensorValue<55)
show_low();
else if(sensorValue>=55 && sensorValue<70)
show_med();
else
show_high();
}
else if(mode==2)
{
if(sensorValue<45)
show_low();
else if(sensorValue>=45 && sensorValue<70)
show_med();
else
show_high();
}
else if(mode==3)
{
if(sensorValue<40)
show_low();
else if(sensorValue>=40 && sensorValue<70)
show_med();
else
show_high();
}
else if(mode==4)
{
if(sensorValue<58)
show_low();
else if(sensorValue>=58 && sensorValue<70)
show_med();
else
show_high();
}
else if(mode==5)
{
if(sensorValue<53)
show_low();
else if(sensorValue>=53 && sensorValue<62)
show_med();
else
show_high();
}
delay(100);
}