02 4 / 2013

Food Waste

So this is an example of the system further along, allowing you to push the button once, without holding it for the timer to start.

PROBLEM FOUND — The counter is counting from the start, not from when the button is pressed. 

Next stage is to have something physical to show the amount of time until the item is going to go off, as at the moment, you move the potentiometer, however you are not sure how long you are setting it for.

Code Below


unsigned long starttimer;

unsigned long timerbegin;

unsigned long elapsedtime;

int potval;

int counterdays;

int button;

int buttonstate;

int buttoncounter;

int counter;

void setup(){


pinMode(11, OUTPUT);

pinMode(8, INPUT);



void loop(){

          potval = analogRead(0);

          counterdays = map(potval, 0, 1023, 1, 7);

 button = analogRead(1);

 buttonstate= map(button,0,1023,10,0);

 starttimer = millis();

if (buttonstate >=5){

buttoncounter ++;



if (buttoncounter >= 1){



 if (starttimer>= 1000* counterdays ){

   digitalWrite(11, HIGH);





  1. projctardy reblogged this from arduinoexperiments
  2. arduinoexperiments posted this