You are reading a single comment by @MrTimcakes and its replies. Click here to read the full conversation.
  • Putting the bins out is one of my chores, grumble grumble, but i always seem to forget when a bin day is, so as a programming kid i thought a calendar is too simple and boring so i broke out the Espruino and converted my bin dates to JSON. This script currently only checks if the specified date is a bin day and if it it prints what type of bin it is. I plan to use a RTC and a LCD to have this as a clock that can also show notifications, but i need to get a RTC for that (I've got some Chinese ones but there's no Espruino modules and i think they're broken anyway). When i add this all i'll need to do is get the RTC time and add a day (You put the bins out the night before) then either check when i update the clock part or every 10 or 30 mins.

    Currently to use just change the date variable to a string like "11/12/14" and press BTN1 or use check()

    var date = "5/6/14";
    
    
    var json = {"6/3/14":"g","13/3/14":"b","20/3/14":"g","27/3/14":"b","3/4/14":"g","10/4/14":"b","17/4/14":"g","25/4/14":"b","1/5/14":"g","9/5/14":"b","15/5/14":"g","22/5/14":"b","30/5/14":"g","5/6/14":"b","12/6/14":"g","19/6/14":"b","26/6/14":"g","3/7/14":"b","10/7/14":"g","17/7/14":"b","24/7/14":"g","31/7/14":"b","7/8/14":"g","14/8/14":"b","21/8/14":"g","29/8/14":"b","4/9/14":"g","11/9/14":"b","18/9/14":"g","25/9/14":"b","1/10/14":"g","9/10/14":"b","16/10/14":"g","12/10/14":"b","30/10/14":"g","6/11/14":"b","13/11/14":"g","20/11/14":"b","27/11/14":"g","4/12/14":"b","11/12/14":"g","18/12/14":"b","24/12/14":"g","2/1/15":"s","8/1/15":"g","15/1/15":"b","22/1/15":"g","29/1/15":"b","5/2/15":"g","12/2/15":"b","19/2/15":"g","26/2/15":"b","5/3/15":"g","12/3/15":"b","19/3/15":"g","26/3/15":"b","2/4/15":"g","10/4/15":"b","16/4/15":"g","23/4/15":"b","30/4/15":"g","8/5/15":"b","14/5/15":"g","21/5/15":"b","29/5/15":"g","4/6/15":"b","11/6/15":"g","18/6/15":"b","25/6/15":"g","2/7/15":"b","9/7/15":"g","16/7/15":"b","23/7/15":"g","30/7/15":"b","6/8/15":"g","13/8/15":"b","20/8/15":"g","27/8/15":"b","4/9/15":"g","10/9/15":"b","17/9/15":"g","24/9/15":"b","1/10/15":"g","8/10/15":"b","15/10/15":"g","22/10/15":"b","29/10/15":"g"};
    
    function check(){
      var type;
      if(!(date in json)){
        console.log("Not a bin day");
      }else{
        switch(json[date]) {
        case "g":
            type = "Green bin";
            break;
        case "b":
            type = "Brown bin";
            break;
        case "s":
            type = "Green & Plastic";
            break;
        }
        console.log("It's a bin day, its the " + type);
      }
    }
    
    setWatch(function(){check();}, BTN1, {repeat:true,edge:"rising", debounce:5/*ms*/});
    
About

Avatar for MrTimcakes @MrTimcakes started