Sendai, Japan

Just an in between stop over, where we almost got stuck as the local transport was going to shutdown due to an earthquake warning.

Yamadera, Japan

Matsushima, Japan

Mt. Takao

Yokohama, Japan

Enochima, Japan

Kamakura, Japan

Aimori, Japan

A freezing start of this years holiday…… Long trip from Tokyo, short stay.

ATTiny85 One Button Timer

For if you have a need. Single switch button with three LEDs to indicate the amount of time you want to set. In the configuration you can set the time per unit (20 minutes in the code below). After turning it on, the three LEDs should start to burn so to check they work, then when pressing the button it will start the time. You can at anytime adjust the time which will then be reset to the amount of time you want. If you want to decrease the time you have to cycle until the end after which it will go back to the lowest setting. ButtonTimerTotal times works in the same way as binary, given the value in the code is 20, the first LED is 20, the second 40(2x) and the last 80(4x). Now by pressing the button you can choose between 20 to 140 minutes of delay before it switches off the timer.  There is also a random time function which is activated when all LEDs are turned off, this will pick a random time between 40(2*) and 140(7*). As the amount of i/o is limited I’ve used an ATTiny85 rather than a complete Arduino, by modifying which pins it is using the code can be used on an Arduino as well.

// Button Timer 1.0 for ATTiny85
// Update 1.1 : Added 0 (no LEDS) as a random timer with a pre-defined minimum and maximum of 7

// Control a device through relay or optocoupler for a set period of time.
// Time can be adjusted during operation, cycle through all option before
// returning to lower values again, following a binary like display.

// Global Initialization

int Timer = 20;       // Default timer value (lowest and incremental factor) = X
int TimerInc = Timer; // Incremental Timer value to calculate Timer changes
int TimeLED[3];       // LEDs indicating time (X, X*2, X*4)
int TimeLEDSP = 0;    // First of the three Pins for the TimeLEDs,
int TimeInSecs;       // Timer expiration counter
int TimerButton = 3;  // Button to change time
int TimerRelay = 4;   // Relay that is on for duration of Timer
int RandomOn = 0;	  // 0 = Random off; 1 = Random on
int RandomMin = 40;   // Minimum random time in minutes

void setup() {
  int SetupTMP;       // Temp Var within Setup
  int SetupLoop = 1;  // Loop Var within Setup

  // Mapping PINs and setting them to either input or output
  for (SetupTMP = 0; SetupTMP < 3; SetupTMP++) {
    TimeLED[SetupTMP] = SetupTMP + TimeLEDSP;
    pinMode(TimeLED[SetupTMP], OUTPUT);
  }
  pinMode(TimerButton, INPUT);
  pinMode(TimerRelay, OUTPUT);
  
  //seed random number generator with noise from an unconnected pin
  randomSeed(analogRead(A0));

}

void loop() {
  int MainTMP;        // Temp Var within Main
  TimeInSecs = 60 * Timer;
  
  // Test Procedure, run all lights wait for TimerButton push, after push TimerRelay turns on
  for (MainTMP = 0; MainTMP < 3; MainTMP++) {
    digitalWrite(TimeLED[MainTMP], HIGH);
  }
  MainTMP = 1;
  
  while (MainTMP == 1) {
    delay(1000);
    if (digitalRead(TimerButton) == HIGH) {MainTMP = 0;}
  }

  for (MainTMP = 0; MainTMP < 3; MainTMP++) {
    digitalWrite(TimeLED[MainTMP], LOW);
  }
  digitalWrite(TimerRelay, HIGH);

  // Main Loop, wait until time runs out or button is pressed to increase time (one sec interval)
  while (TimeInSecs > 0) {

    delay(1000);        // 1 Second delay
    TimeInSecs--;
    
    // Button is pressed, add and recalculate time, if max is reached go to 0/random value
    if (digitalRead(TimerButton) == HIGH) {
	  if (RandomOn == 1) {
	    Timer = 0;
		RandomOn = 0;
	  }
      Timer += TimerInc;
      if (Timer > (TimerInc * 7)) {Timer = 0;}
      if (Timer > 0) {TimeInSecs = 60 * Timer;}
	  else { 
	    TimeInSecs = (random(RandomMin, (7 * Timer)) * 60);
		RandomOn = 1;
	  }
    }

    // Show Time through LEDs
    MainTMP = Timer;
    if (MainTMP >= (TimerInc * 4)) {
      digitalWrite(TimeLED[2], HIGH);
      MainTMP -= (TimerInc * 4);
    }
    else {
      digitalWrite(TimeLED[2], LOW);
    }
    if (MainTMP >= (TimerInc * 2)) {
      digitalWrite(TimeLED[1], HIGH);
      MainTMP -= (TimerInc * 2);
    }
    else {
      digitalWrite(TimeLED[1], LOW);
    }
    if (MainTMP >= TimerInc) {
      digitalWrite(TimeLED[0], HIGH);
      MainTMP -= TimerInc;
    }
    else {
      digitalWrite(TimeLED[0], LOW);
    }
    
  }

  // Turn relay off after timer has expired
  digitalWrite(TimerRelay, LOW);

}

One Button Timer Build

My own build on a little bit of perfboard and put together with a relay in the smallest box I had lying around.