A Smart Coffee Cup Warmer

My project is a coffee cup warmer. It more than just a typical coffee cup warmer though; it’s a smart coffee cup warmer.  It saves energy by checking if there is coffee in your cup to be warmed.  It also has a few other features like two levels of heating (a hot one for myself and warm one for my wife) as well as two programable cup sizes to ensure that you’re always warming your coffee down to the last drop!

CODE

// constant variables:
const int ledHot = 13; // the number of the red hot mode indicator LED
const int ledCool = 12; // the number of the yellow cool mode indicator LED
const int ledCup1 = 5; // the number of the cup 1 indicator LED
const int ledCup2 = 3; // the number of the cup 2 indicator LED

const int buttonHeat = 8; // the number of the heat mode changer button
const int buttonPower = 7; // the number of the power on/off button
const int buttonCup = 2; // the number of the cup selection button

const int HeatPadPin = 9; //the head pad pin
const int pressurePin = 0; //pressure sensor pin
// variables will change:
boolean buttonHeatState = HIGH; // variable for reading the heat pushbutton status
boolean lastbuttonHeatState = LOW; // previous reading from the pin
boolean buttonPowerState = LOW; // variable for reading the power pushbutton status
boolean lastbuttonPowerState = HIGH;
boolean buttonCupState = HIGH; // variable for reading the cup pushbutton status
boolean lastbuttonCupState = LOW; // previous reading from the pin

int buttonCupTimer = 0;
boolean timerState = LOW;
int fadeValue = 254;

boolean HeatMode = HIGH;
boolean PowerMode = LOW;
boolean CupMode = HIGH;
boolean CupFadeSequence = true;
int CupType;
int OtherCupType;
int timer;

//cup weights

int cup1weight = 270;
int cup2weight = 175;

//weight variables

int coffeeweightThreshold = 100;
boolean coffeeAvailable = false;

//heat variables

int highHeat = 45;
int lowHeat = 20;
int heat;

 

void setup() {
// initialize the LED pins as outputs:
pinMode(ledHot, OUTPUT);
pinMode(ledCool, OUTPUT);
pinMode(ledCup1, OUTPUT);
pinMode(ledCup2, OUTPUT);
pinMode(HeatPadPin, OUTPUT);

// initialize the pushbutton pin as an input:
pinMode(buttonHeat, INPUT);
pinMode(buttonPower, INPUT);
pinMode(buttonCup, INPUT);

Serial.begin(9600);
}

void loop(){

if (digitalRead(buttonPower) == HIGH && lastbuttonPowerState == LOW) {
PowerMode = !PowerMode;
lastbuttonPowerState = HIGH;
}
else {
lastbuttonPowerState = digitalRead(buttonPower);
}

 

 
//Get heating mode: hot or cool.
if (digitalRead(buttonHeat) == HIGH && lastbuttonHeatState == LOW && PowerMode == HIGH) {
HeatMode = !HeatMode;
lastbuttonHeatState = HIGH;
}
else {
lastbuttonHeatState = digitalRead(buttonHeat);
}
//Turn on hot heating mode LED and turn off cool mode LED.
if (HeatMode == HIGH && PowerMode == HIGH) {
digitalWrite(ledHot, HIGH);
digitalWrite(ledCool, LOW);
}
//Turn on cool heating mode LED and turn off hot mode LED.
if (HeatMode == LOW && PowerMode == HIGH) {
digitalWrite(ledHot, LOW);
digitalWrite(ledCool, HIGH);
}
//Turn off both heating mode LEDs
if (PowerMode == LOW){
digitalWrite(ledHot, LOW);
digitalWrite(ledCool, LOW);
}

//Get cut mode: size 1 or size 2.
if (digitalRead(buttonCup) == HIGH && CupFadeSequence == true && PowerMode == HIGH) {
//Read which cup type is the active one.

if (timerState == LOW){
buttonCupTimer = millis();
timerState = HIGH;

}

timer = millis() – buttonCupTimer; //read how long the button has been held down.

//fade LED to indicate that the cup weight read & set process is about to start.
if (timer >= 1000 && fadeValue >= 0){
fadeValue = fadeValue – 1;
analogWrite(CupType, fadeValue);
delay(10);
}
//flash light to indicate cup weight read & set is done.
if (fadeValue <= 0){
digitalWrite(CupType, LOW);
delay(300);
digitalWrite(CupType, HIGH);
delay(300);
digitalWrite(CupType, LOW);
delay(300);
digitalWrite(CupType, HIGH);
delay(300);
digitalWrite(CupType, LOW);
delay(300);
digitalWrite(CupType, HIGH);
fadeValue = 254;
CupFadeSequence = false;
if (CupMode == HIGH){
cup1weight = analogRead(pressurePin);
}
else {
cup2weight = analogRead(pressurePin);
}
}
}

else {
lastbuttonCupState = digitalRead(buttonCup);
}

//change cup mode if cup select switch wasn’t held for over 1 second
//turn off all cup mode indicator lights in order to reset to the correct reading
if (digitalRead(buttonCup) == LOW && timer < 1000 && timer > 0) {
CupMode = !CupMode;
digitalWrite(ledCup1, LOW);
digitalWrite(ledCup2, LOW);
timer = 0;
}
//turn on the correct cup mode LED indicators.
if (digitalRead(buttonCup) == LOW) {
digitalWrite(OtherCupType, LOW);
digitalWrite(CupType, HIGH);
CupFadeSequence = true;
timerState = LOW;
fadeValue = 254;
if (CupMode == HIGH){
CupType = ledCup1;
OtherCupType = ledCup2;
}
else{
CupType = ledCup2;
OtherCupType = ledCup1;
}
}

if (PowerMode == LOW){
digitalWrite(ledCup1, LOW);
digitalWrite(ledCup2, LOW);
}

//read coffee cup and coffee status
if (PowerMode == HIGH) {
if (CupMode == HIGH && analogRead(pressurePin) >= (cup1weight + coffeeweightThreshold)){
coffeeAvailable = true;
}
if (CupMode == LOW && analogRead(pressurePin) >= (cup2weight + coffeeweightThreshold)){
coffeeAvailable = true;
}
}
else {
coffeeAvailable = false;
}

//begin heating coffee
if (HeatMode == HIGH && PowerMode == HIGH && coffeeAvailable == true){
analogWrite(HeatPadPin,highHeat);
heat = highHeat;
}
if (HeatMode == LOW && PowerMode == HIGH && coffeeAvailable == true){
analogWrite(HeatPadPin,lowHeat);
heat = lowHeat;
}
if (coffeeAvailable == false){
analogWrite(HeatPadPin,0);
heat = 0;
}

}

1 comment to A Smart Coffee Cup Warmer

  • Hudson Kenneth Pridham

    Sorry, just realized my video was listed as private on YouTube. I’ve just made it public so you all should be able to view it now.