Pylons for safety in the dark

 

With so many people walking around in the dark and looking for switches, I figure this will help when walking and bumping into things:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

code:
#define LED_PIN 3
#define SENSOR_PIN A0

#define SENSE_THRESHOLD 150
#define TRACK_THRESHOLD 230
#define DEBOUNCE_CYCLES 30
#define START_TRACKING_CYCLES 180
#define END_TRACKING_CYCLES 210
#define HAND_MINIMUM_CHANGE 15

int adc_input = 0;
int pwm_output = 0;
int stored_bright = 0xFF;
int target_bright = 0;
int hand_tracked_bright = 0;

boolean lamp_lighted = false;
boolean hand_tracking = false;

unsigned char hand_cycles = 0;
unsigned char debounce_cycles = 0;

int sample_1 = 0;
int sample_2 = 0;
int sample_3 = 0;
int sample_4 = 0;
void setup() {
analogWrite(LED_PIN, 0);
}

void loop() {
sample_1 = analogRead(SENSOR_PIN); delay(1);
sample_2 = analogRead(SENSOR_PIN); delay(1);
sample_3 = analogRead(SENSOR_PIN); delay(1);
sample_4 = analogRead(SENSOR_PIN); delay(1);
adc_input = (sample_1 + sample_2 + sample_3 + sample_4) >> 2;

if(debounce_cycles)
debounce_cycles -= 1;
else {
if(hand_tracking) {
if(adc_input > SENSE_THRESHOLD) {
if(adc_input > TRACK_THRESHOLD + 0xFF)
hand_tracked_bright = 0;
else if(adc_input < TRACK_THRESHOLD)
hand_tracked_bright = 0xff;
else
hand_tracked_bright = 0xFF – (adc_input – TRACK_THRESHOLD);

if(abs(target_bright – hand_tracked_bright) > HAND_MINIMUM_CHANGE || !lamp_lighted) {
target_bright = (target_bright + (hand_tracked_bright > 8 ? hand_tracked_bright : 8)) >> 1;
lamp_lighted = true;
}
hand_cycles = 0;
}
else {
target_bright = pwm_output;
stored_bright = pwm_output;
hand_cycles += 1;
if(hand_cycles == END_TRACKING_CYCLES) {
hand_tracking = false;
hand_cycles = 0;
}
}
}
else {
if(adc_input > SENSE_THRESHOLD) {
hand_cycles += 1;
if(hand_cycles == START_TRACKING_CYCLES) {
hand_tracking = true;
hand_cycles = 0;
}
}
else {
if(hand_cycles) {
lamp_lighted = !lamp_lighted;
target_bright = lamp_lighted ? stored_bright : 0;
debounce_cycles = DEBOUNCE_CYCLES;
}
hand_cycles = 0;
}
}
}

if(pwm_output != target_bright) {
if(pwm_output > target_bright && pwm_output > 0) –pwm_output;
if(pwm_output < target_bright && pwm_output < 0xFF) ++pwm_output;
analogWrite(LED_PIN, pwm_output);
delay((0xFF – abs(target_bright – pwm_output)) >> 5);
}
}

 

Jerem’y Socially Interactive House Plant

Hi Everyone:

Here is a picture of my socially interactive house plant. The idea was to have a plant that needed talking to. The light colours
would change either due to room lighting or someone speaking to the plant. Also, there would be a Processing app that would
visually indicate the “happiness” of the plant (that’s a work in progress!). Basically, a stress reliever for the office cubicle!!!!

It worked pretty well except the microphone control was very unpredictable (ok, barely worked!).  I’m going to figure out why!
When  I do I will add a follow-up post.

Postscript:

I got the microphone to work! New video posted and I have updated the code.

 

Here is the video:

 

Here is the Second Video with the Audio Sensor (Mic) Working and the code cleaned up!

 

Here are the schematics (Made with Fritzing!!!!): 

Here is the layout in a manner (schematic) I find much more difficult that the visual design below!

 

 

 


 

 

 

 

 

 

 

 

 

 

 

 

 

 

‘ *******************************************************

Here is the code:

‘**********************************************************

/ Jeremy Littler
// “Hello Mr (or Mrs) Plant
// As I said that 10000000 Times!
// Interact with your Unpredicatble Plant.
// All Code is Free for Anyone to Use
//  October 2012

//       .;:;:.
//       ::;:;:
//     _ ‘;:;;’
//     >’. ||  _
//     `> \||.'<
//      `>|/ <`
//        `||/`
//  ^jgs^^^^^^^^^^^

//
// TO HARD RESET CONNECT ONE BUTTON POIN
// TO Reset and the other to ground

// Keep Track of where it should be R G or B
int showlightbank = 0; // determines which light bank get displayed

int hasbooted = 0; // do startup sequence;
int plantisawaken = 0; // make sure you can only wake the plan once
int istalkingtoplant =0; // someone is talking to the plant;

// Source: Arduino Cookbook – Detecting Light – Page 186
const int lightsendor = A5;
int ambientlightlevel= 100;

// Source: Arduino Cookbook – Page 198
const int pinMic = A0; //analog input connected to mic AUD

const int ledPin13 = 13; //digital output connected to LED 0
const int middleValue = 512; //The middle range of analog values
const int numberOfSamples=128; //number og readings  tasken

int sample; //value read from mic
long signal; //reading post DC offset removal
long averageReading; // the average of that loop of readings

long runningAverage = 0; //running average of calculated values
const int averagedOver=16; // how quickly new values affect the runniong average
const int threshold=19000; // The level the light (motor turns on)

void setup() {

Serial.begin(19200);

// For the Plant Lights
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(8, OUTPUT);

}

void loop()
{

// Check for Startup Sequence
if (hasbooted ==0) {
hasbooted = 1;
digitalWrite(8, LOW);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
delay(2000);
digitalWrite(8, HIGH);
digitalWrite(12, HIGH);
digitalWrite(13, LOW);
delay(2000);
digitalWrite(8, HIGH);
digitalWrite(12, LOW);
digitalWrite(13, HIGH);
delay(2000);
digitalWrite(8, LOW);
digitalWrite(12, HIGH);
digitalWrite(13, HIGH);

}

// ***************
// Ambient Light
// **************

// Checks the Light Sensor value
ambientlightlevel = analogRead(lightsendor);
// Serial.println(ambientlightlevel);
//delay(200);
// Serial.println(ambientlightlevel);

// If the ambinet light level drops below 50. Then it is getting dark
// Dont wake up as the light must be on
if (istalkingtoplant == 0) {
if (ambientlightlevel <= 70)  {
// Red A Night
// Sailors Delight
digitalWrite(8, HIGH);
digitalWrite(12, HIGH);
digitalWrite(13, LOW);
}

if  (ambientlightlevel >= 71 && ambientlightlevel <= 125) {
// Blue A Night
// in Mid Light
digitalWrite(8, HIGH);
digitalWrite(12, LOW);
digitalWrite(13, HIGH);
}

if  (ambientlightlevel > 125)  {
// Green when its hot
digitalWrite(8, LOW);
digitalWrite(12, HIGH);
digitalWrite(13, HIGH);
}
}

// Touching or Talking. This thing is VERY unpredictable.
// Source: Arduino Cookbook – Page 198

// This code what not used (except sample = analogRead(pinMic);) as I found reading the
//pin mic sufficient. However, I have included it
//as this may work better for some microphones

long sumOfSquares = 0;
for (int i=0; i<numberOfSamples; i++) {
sample = analogRead(pinMic); //take a reading’
Serial.println(sample);
// Serial.println( sample);
signal = (sample-middleValue); // work out the offset
signal *= signal; //square the value
sumOfSquares += signal; // add to the total

}

// This code what not used (except sample = analogRead(pinMic);) as I found reading the
//pin mic sufficient. However, I have included it
//as this may work better for some microphones
// Calculates the Running Average
averageReading= sumOfSquares/numberOfSamples; // calculates running averge
runningAverage= (((averagedOver-1)*runningAverage)+averageReading)/averagedOver;

delay(150);

// Is the “level” from the mic sensor picking anything up. Movement, Sound.

if (sample >= 600) {
long runningAverage = 0;
istalkingtoplant = 1;
Serial.flush();

// if plantis
// Then put on a light show
for (int i=0; i <= 8; i++){
plantisawaken = 1;
Serial.println(“flicker”);

digitalWrite(8, LOW);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
delay(150);
digitalWrite(8, HIGH);
digitalWrite(12, LOW);
digitalWrite(13, HIGH);
delay(150);
digitalWrite(8, LOW);
digitalWrite(12, LOW);
digitalWrite(13, HIGH);
delay(150);
digitalWrite(8, HIGH);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
delay(150);
digitalWrite(8, LOW);
digitalWrite(12, HIGH);
digitalWrite(13, HIGH);

}
Serial.begin(19200);

} else {
istalkingtoplant = 0;

}

}

 

Mjölk

 

Mjölk (pronounced MI-YELK) is an interactive milk carton holder which indicates how much milk is left in the container and/or if the temperature of the milk carton has gone above the set/desired degree.

Mjölk Video

Mjölk Documentation

Mjölk Process Video

 

 

Bellerade: The Masked Doorbell

Bellerade : The Masked Doorbell

http://www.youtube.com/watch?v=9xQO2gmgY9o

BONJOUR BELLERADE

Bellerade is a masked doorbell, designed to shake up the workspace at 205 Richmond a little. It’s my take on a more interesting, pleasing way to enter a room. I’ve often forgotten my student card when running around 205 Richmond, and for a while my card access was denied for room 7610, so I was constantly knocking on the door. It started to feel a bit intrusive and annoying – maybe because I’m extremely sensitive to sound, and maybe because of the stink eye from Curatorial students I’d often get on entry. I thought one day about how instead of a traditional knock or bell to signify that I’d like to enter a room, wouldn’t it be neat if at the push of a button, and dependent on the position of a variable resistor, a different song or sound could play as a “doorbell”. It could be humourous; it could be soothing; it could be scary – sounds and music can be so lovely and nostalgic sometimes. Most importantly, it could be unique and changed at the turn of a knob and the push of a button….or a quick and easy upload of new tracks to an SD card.

THE MASK 

Hallowe’en’s just over a fortnight away, and it’s definitely one of my favourite excuses to throw on a getup. I’ve been costume clad every year since I was 1. Sexy costumes have never been my thing and are generally lame, so when thinking about how to disguise an unsightly tangled mess of wires and microprocessors that I intended to make into a sound and song spewing doorbell, I thought, what better than a gory mask?  It worked well in terms of my ability to incorporate LEDs as eyes and a mouth, mostly by virtue of the fact that I couldn’t get the button to work with the variable resistor in order to toggle tracks. The resistor would work on its own to change wav files, but the button for some reason only wanted to STOP the music that would automatically play, and not start it…I was stuck.  And while aesthetically the volume knob worked well as a makeshift mask nose, and as a way for the user to turn the sound on and off, it encouraged a type of awkward nasal assault-like user interaction. Digging for gold is an understatement. And most importantly, the doorbell mechanism didn’t really work. Shino was over trying to save me. We tested a number of button code examples and no dice. So LEDs came through in the clutch as a way to increase the mechanisms for non nasal assault-like user interaction, and the variable resistor seemed to work well at controlling the LED high / lows with a few simple if / else statements. So it’s a doorbell in progress. For now, it’s a scary mask that can live on the door for Hallowe’en that flashes lights and plays strange sounds when you turn knobs. I think it’s fun.

THE HARDWARE

– Adafruit Waveshield kit for Arduino

  • Can play any uncompressed 22KHz, 16bit, mono Wave (.wav) files of any size. . Check out the demo video/audio at the webpage
  • Output is mono, into L and R channels, standard 3.5mm headphone jack and a connection for a speaker that is switched on when the headphones are unplugged
  • Files are read off of a FAT16/FAT32-formatted SD/MMC card

– mini speaker

– Arduino Uno x 2 (1 to plug into Waveshield, another for LEDs)

– breadboard for LEDs

– 6 LEDs

– 1 variable resistor

– 1 9V battery to power LEDs

– 1 5V battery to power speaker

– 1 weird looking mask

CODE

  • http://arduino.cc/en/Tutorial/AnalogInput  (For LEDs)
  • Arduino > Examples > Wave HC > daphc   (For sound)

LIBRARIES

Wave HC library comes with the Adafruit WaveShield

iMac Heat Sensor

http://vimeo.com/51114107

So it all started with freezes when attempting to render my motion graphics in FCPX. Very frustrating. So I thought: how can I use my Arduino to avoid this freeze ups? I noticed that when my iMac would heat up, the render times would be much slower and the possibility of freezes would increase. I found a tutorial online on using a heat sensor to trigger alerts. I programmed it to reactive in different ways to 3 different heat levels:

1 level – light turns on

2 level – buzzer buzzes

3 level – buzzer buzzes at a higher frequency

What I enjoyed most from this first Arduino project was the process. Understanding each line of code and deconstructing it to see what would happen. This was a great way to learn. Also adding the second and third heat levels was my variable on the original tutorial.

 

 

// declare variables
// derived from youtube.com/oneHand tutorial
float tempC;
int tempPin = 0; // Temp sensor plugged analog pin 0
int ledPin = 13; // led is plugged into pin 13
int buzzPin = 7; // led is plugged into pin 13
// write set up function
void setup()
{
Serial.begin(9600); // opens serial port to communicate with temp sensor
pinMode(ledPin, OUTPUT);
pinMode(buzzPin, OUTPUT);
}
// write loop that will control what we want the arduino to do with temp reaout
void loop()
{
tempC = analogRead(tempPin); //taking temp pin reading and setting it equal to tempC variable
tempC = (5.0*tempC*100.0)/1024.0; // convert analog input to a tempurature in celcius
Serial.println((byte)tempC); // will output the converted temp to PC
if (tempC >22)
{
digitalWrite(ledPin, HIGH);
}
else
{
digitalWrite(ledPin, LOW);
}
delay(1000);

if (tempC >25 && tempC 30)
{
digitalWrite(buzzPin, HIGH);
}
else
{
digitalWrite(buzzPin, LOW);
}
delay(10);

}

Procrastination Meter

Procrastination.. everyone knows it’s bad but still do it at some point.

For me it helps when I realized how much time I drifted off, so I wanted to build a procrastination-meter to be a reminder of guilt and do even more work.

It can be attached on to the wall around your workspace. At first it may seem like a blank picture frame, but once you start procrastinating the time will start to count and for every hour one LED would appear (5 secs for the demo). As the LEDs are hidden behind the black tissue paper, it is not possible to tell what image it is. It will slowly reveal itself as you procrastinate. It also acts as a dynamic decorative item in your space.

The physical form and wiring is not complicated. The coding was tricky for me as this is my first time with Arduino.

I got the basic code from “Getting started with Arduino” book on how to make the LEDs light up in timed intervals and on the Arduino forum on how to control multiple LEDs with one button: http://arduino.cc/forum/index.php?topic=124707.0

Here is the code.. (Thanks to Nick and Ruzette for their help!) I have to admit as of now it works fine up until after it paused and has to start counting again. It will just have to be start over for now.

 

——————————————————————————————————————————–

int LED1Pin = 13;   // define 1st LED
int LED2Pin = 12;  // define 2nd LED
int LED3Pin = 11;  // define 3rd LED
int LED4Pin = 10;  // define 4th LED
int LED5Pin = 9;  // define 5th LED
int LED6Pin = 8;  // define 6th LED
int LED7Pin = 6;  // define 7th LED
int LED8Pin = 5;  // define 8th LED
int LED9Pin = 4;  // define 9th LED
int LED10Pin = 3;  // define 10th LED

int BUTTON = 7;  // the input pin where the
// pushbutton is connected
int val = 0;     // val will be used to store the state
// of the input pin

int currentstate = 0;   // 0 = LED off and 1 = LED on and 2 = pause

long lastChange = 0;

unsigned long startTime = 0;

void setup() {
pinMode(LED1Pin, OUTPUT);   // tell Arduino LED is an output
pinMode(LED2Pin, OUTPUT);
pinMode(LED3Pin, OUTPUT);
pinMode(LED4Pin, OUTPUT);
pinMode(LED5Pin, OUTPUT);
pinMode(LED6Pin, OUTPUT);
pinMode(LED7Pin, OUTPUT);
pinMode(LED8Pin, OUTPUT);
pinMode(LED9Pin, OUTPUT);
pinMode(LED10Pin, OUTPUT);
pinMode(BUTTON, INPUT); // and BUTTON is an input

Serial.begin(9600);
}
void loop(){
val = digitalRead(BUTTON); // read input value and store it
long counttime = millis() – lastChange;
Serial.print(“Current val is : “);
Serial.println(counttime);

// check if button is pushed and if in off state
if ((val == HIGH) && (currentstate == 0)){
currentstate = 1;
lastChange = millis();
}
else if ((val == HIGH) && (currentstate == 1)){
currentstate = 2;
}
else if ((val== HIGH) && (currentstate == 2)){
currentstate = 1;
lastChange = millis() – lastChange;
}

if ((currentstate == 1) && (millis() – lastChange) >= 5000) {
digitalWrite(LED4Pin, HIGH); // turn LED ON

}
if ((currentstate == 1) && (millis() – lastChange) >= 10000) {
digitalWrite(LED1Pin, HIGH); // turn LED ON

}
if ((currentstate == 1) && (millis() – lastChange) >= 15000) {
digitalWrite(LED10Pin, HIGH); // turn LED ON

}

if ((currentstate == 1) && (millis() – lastChange) >= 20000) {
digitalWrite(LED2Pin, HIGH); // turn LED ON

}
if ((currentstate == 1) && (millis() – lastChange) >= 25000) {
digitalWrite(LED5Pin, HIGH); // turn LED ON

}
if ((currentstate == 1) && (millis() – lastChange) >= 30000) {
digitalWrite(LED9Pin, HIGH); // turn LED ON

}

if ((currentstate == 1) && (millis() – lastChange) >= 35000) {
digitalWrite(LED7Pin, HIGH); // turn LED ON

}

if ((currentstate == 1) && (millis() – lastChange) >= 40000) {
digitalWrite(LED3Pin, HIGH); // turn LED ON

}

if ((currentstate == 1) && (millis() – lastChange) >= 45000) {
digitalWrite(LED6Pin, HIGH); // turn LED ON

}

if ((currentstate == 1) && (millis() – lastChange) >= 50000) {
digitalWrite(LED8Pin, HIGH); // turn LED ON

}
}
——————————————————————————————————————————–

In the future, the input of logging on Facebook or other procrastination websites, can be sent directly to system.

It can be in the living space and be a display piece. That’s also one of the main ideas behind, the irony that you are procrastinating but at the same time actually generating something. A display of you procrastination.

 

 

CODE SOURCES

Throughout the making of ‘Work Buds’ different codes were used from the public domain in order to successfully make your buds work!

These include:

The PING))) example in arduino:

The Servo Sweep example in arduino:

Apart from this and some research into different ways of controlling the servo, a lot of coding assistance was provided by Nick.

Thanks!

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;
}

}