javier muñoz sáez
Published © GPL3+

Hacking My Toaster

Lets control the exact time our toast is being cooked with a precision ±10ms. LINE VOLTAGE, BE CAREFUL.

IntermediateShowcase (no instructions)2 hours7,222

Things used in this project

Hardware components

TOASTER
the cheapest i found
×1
Arduino UNO
Arduino UNO
×1
Relay (generic)
×1
Micro Limit Switch Plate
OpenBuilds Micro Limit Switch Plate
×1
oled screen
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Hot glue gun (generic)
Hot glue gun (generic)

Story

Read more

Schematics

wiring

WIRING THINGIES

Code

The main thing

Arduino
controls your toaster cooking time
//coded by javier muñoz sáez, 12/12/2017
//javimusama@gmail.com

#include <SPI.h>//liraries for manage the OLED display
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET A6

#define interruptPin 2
#define relePin      3

float toastingtime=3000;//time in milisenconds
float starttime=0;
bool flag=0;  

Adafruit_SSD1306 display(OLED_RESET);

void setup() {
  pinMode(relePin,OUTPUT);
  pinMode(A4,OUTPUT);//I2C OLED CONTROL
  pinMode(A5,OUTPUT);
  
  digitalWrite(relePin,LOW);
  attachInterrupt(digitalPinToInterrupt(interruptPin), TOASTaction, RISING);//activates the function when the logic level of interruptPin rises so: (__-HERE------------------_____)
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //initialize with the I2C addr 0x3C (128x64)
  display.clearDisplay();//initial flush to black of the screen

  display.setCursor(0,0);  //initial message
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.println("TOSTADORA");
  display.setTextSize(1);
  display.setCursor(0,55);display.println("Javier Munoz Saez");
  display.display();
  delay(3000); //for 3 seconds
  display.clearDisplay();
  display.display();
  
}

void loop() {
  if(flag==1){//check just when we need to
    OLEDcountdown();
    whentostop();

  }else{
 OLEDtext();
  }
}

void TOASTaction(){//interruption from pin 2
  flag=1;//the toasting just started!
  starttime=millis();//get start time
}

void whentostop(){//checks time and activates relay
  if(toastingtime<=millis()-starttime){//when toasting time is smaller than the time since the toaster started
    digitalWrite(relePin,HIGH);//relay!
    delay(50);
    digitalWrite(relePin,LOW);
    flag=0;//get back to idle mode.
    OLEDTOAST();
  }
  
}

void OLEDcountdown(){
  int tiempo=toastingtime-(millis()-starttime);
  
  display.clearDisplay();
  display.setTextSize(3);
  display.setCursor(0,30);display.println(tiempo);  display.setCursor(80,30);display.println("ms");
  display.display();
  
}

void OLEDtext(){
    display.clearDisplay();
    display.setCursor(0,0);  
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.println("HIGH      PRECISION TOASTER");

  display.display();

}

void OLEDTOAST(){
    display.clearDisplay();
    display.setCursor(0,0);  
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.println("TADAAAA :)");
  display.display();
  delay(3000);
}

Credits

javier muñoz sáez

javier muñoz sáez

13 projects • 84 followers
Electronic engineer and sparky person. I make tutorials so my future self doesnt need to remember how he did the thing

Comments