Beverage Level Detector

Made by Muhammad Faizan Zafar

A refrigerator, in the future may have the ability to know and report the quantities of beverages stored in it. This project is an attempt to create one such system which detects the level of the beverage available and reports it to the cloud. The system utilizes diffused ambient light and light dependent resistors to check the level of the beverage.

Created: January 28th, 2015

0
int LDR1Pin = D4;    
int ledPin =  D3;
int LDR2Pin = D2;
int led2Pin = D5;      


int LDR1State = 0;
int LDR2State = 0;         

void setup() {
  Spark.variable("CokeLevel", &LDR1State, INT);
  pinMode(ledPin, OUTPUT);
  pinMode(led2Pin, OUTPUT);
  
  pinMode(LDR1Pin, INPUT);
  pinMode(LDR2Pin, INPUT);
}

void loop(){

  LDR1State = digitalRead(LDR1Pin);
  LDR2State = digitalRead(LDR2Pin);


  if(LDR1State == LOW && LDR2State == LOW  ) {
  
    digitalWrite(ledPin, HIGH);
    digitalWrite(led2Pin, HIGH);
  }
  else if(LDR1State == HIGH && LDR2State == LOW){
  
    digitalWrite(ledPin, HIGH);
    digitalWrite(led2Pin, LOW);
    }
    else if (LDR1State == HIGH && LDR2State == HIGH){
      digitalWrite(ledPin, LOW);
      digitalWrite(led2Pin, LOW);
    }
  }
Click to Expand
0

The code uses the if, else if statements to define the conditional logic for sensing level.

0

This picture shows how the LEDs correspond to a full bottle of diet coke.

0

This picture shows the corresponding LED output with a less than full level but not empty bottle of Diet Coke. The resolution of such a level detection system can be increased by adding more LDRs. 

0

An empty bottle corresponds to both LEDs turned off. 

0

The ambient light from the sides may affect the output of the system, therefore the LDRs are placed inside cups to eliminate light from the sides.

x
Share this Project


About

A refrigerator, in the future may have the ability to know and report the quantities of beverages stored in it. This project is an attempt to create one such system which detects the level of the beverage available and reports it to the cloud.

The system utilizes diffused ambient light and light dependent resistors to check the level of the beverage.