Hackster is hosting Hackster Holidays, Ep. 7: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 7 on Friday!
ardutronic
Published © CC BY-NC-SA

How to Improve Focus With Pomodoro

I often have trouble focusing on what I should do. This device will help me!

BeginnerFull instructions provided5 hours821
How to Improve Focus With Pomodoro

Things used in this project

Hardware components

ATtiny85
Microchip ATtiny85
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Schematic

Code

pomodoro.ino

Arduino
//Pin connected to latch pin (ST_CP) of 74HC595
const int latchPin = 1;
//Pin connected to clock pin (SH_CP) of 74HC595
const int clockPin = 2;
//Pin connected to Data in (DS) of 74HC595
const int dataPin = 0;
bool lightOn;
void setup() {
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(3, INPUT);

  lightOn = false;
  light(false);
Serial.begin(9600);
}


void loop() {
  pomodoro();
  Serial.println(digitalRead(3));
}

void light(bool state) {
  byte val = 255;
  if (state == false) val = 0;

  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, val);
  digitalWrite(latchPin, HIGH);
}

void registerWrite(int whichPin, int whichState) {
  // the bits you want to send
  byte bitsToSend = 0;

  // turn off the output so the pins don't light up
  // while you're shifting bits:
  digitalWrite(latchPin, LOW);

  // turn on the next highest bit in bitsToSend:
  bitWrite(bitsToSend, whichPin, whichState);

  // shift the bits out:
  shiftOut(dataPin, clockPin, MSBFIRST, bitsToSend);

  // turn on the output so the LEDs can light up:
  digitalWrite(latchPin, HIGH);
}

void pomodoro()
{
  if (digitalRead(3) == 1)
  {
    delay(500);
    for (int i = 0; i <= 5; i++) {
      delay(10);
      light(true);
    }

    if (digitalRead(3) == 0)
    {
      for (int i = 5; i >= 0; i--) {
        if (digitalRead(3) == 1)
        {
          break;
        }
        delay(10000);
        light(false);
      }
    }
    for (int a = 0; a < 10; a++)
    {
      for (int i = 5; i >= 0; i--) {
        delay(100);
        light(true);
      }

      for (int i = 5; i >= 0; i--) {
        delay(100);
        light(false);
      }
    }
  }
}

Credits

ardutronic
39 projects • 40 followers
I'm 20 years old student of electronic technical college. I'm passionate about electronics as well as editing movies

Comments