• Skip to primary navigation
  • Skip to main content
  • Skip to footer

VapOven

Induction heaters for DynaVap. Get baked!

  • Home
  • Shop
    • Rechargeable
    • Wall Powered
    • VapOven Kits
    • Accessories
  • Roll Your Own
    • Videos, Diagrams and Tutorials
    • VapOven Kits
    • Tools and components
  • Contact
  •  

VapOven Arduino Shield Advanced Code

Pulse Heating

This is a more advanced program for your VapOven Arduino Shield, it includes double click to pulse heat – very similar to the slowCook feature on our production VapOvens.

Pulse heating allows your induction heater to heat up more slowly and allows the heat to slowly spread through the DynaVap tip and your material for a more even heat, resulting in bigger clouds.

Simply copy and paste the code below into the Arduino IDE and upload to your VapOven Arduino Shield to add pulse heating to your IH project.

If you have any questions about the code or need assistance uploading it to your VapOven Arduino Shield , let me know and I’ll do my best to help.

The VapOven Arduino Shield Solderless Kit

/*
 * Advanced code for the VapOven Arduino Shield
 * 
 *   ***DOUBLE CLICK TO PULSE HEAT***
 * 
 * turns on the IH module and light up LED1 when the trigger button is pressed
 * turns on pulse heating with double click of the button
 * uses the RGB LED as a battery indicator – green when battery is good, red when battery is low.
 * temperature cutoff monitors the temperature and will not activate the IH if over 60 deg Centigrade
 * 
 * This code is free to use and modify for personal use. It is released on the "You owe me a bud" licence - if we ever meet, you promise to provide me with a bud.
 */
 
//pins

int triggerPin = 3;

//LEDs
int LED12v = 2;

int LED1 = 4;
int LED2 = 5;
int intLED = 13;

int blueRGB = 9;
int greenRGB = 10;
int redRGB = 11;

//inputs
int buttonPin = 8;
int potPin = A7;

//sensors
int tempPin = A1;
int voltSensorPin = A6;

float voltage; //battery voltage
double lowBatteryThreshold = 10;

//vaiables for the button press and timeout function
bool buttonState;
bool lastButtonState = LOW;
long buttonPressStart;


unsigned long lastDebounceTime = 0;  // the last time the output pin was toggled
unsigned long debounceDelay = 50;    // debounce delay - can adjust this to make button less sensitive

bool ovenOn = LOW;

int tempC;
int tempCutOff = 60;  //temperature in Celcius to stop IH activating



//pulse mode double click bits
int stateCount = 0;

long firstPressTime;

long buttonTimer = 600;

long timeOut = 800;
long timeOutTimer = 0;

bool pulseMode = false;
long pulseModeStartTime = 0;
int pulseModeDelay = 5000;

//for the pulse heat mode
long pulseOvenTime = 500; //adjust this value to change speed of pulse
long pulseOvenStart = 0;  

float loopTime;



void setup() {
  
//set up all the pins  
  pinMode(buttonPin, INPUT);
  pinMode(triggerPin, OUTPUT);
  pinMode(LED12v, OUTPUT);
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(blueRGB, OUTPUT);
  pinMode(greenRGB, OUTPUT);
  pinMode(redRGB, OUTPUT);
  pinMode(intLED, OUTPUT);
  
  delay(200);


}



void loop() {
  
  loopTime = millis();


//check the temperature
  tempC = getTemp();


//check the battery voltage (if the button isn't pressed)
  if(ovenOn == LOW && pulseMode == LOW) voltage = getVoltage();


//set the RGB LED colour to indicate battery level
  if(voltage >= lowBatteryThreshold){
    digitalWrite(redRGB, LOW);
    digitalWrite(greenRGB, HIGH);
    digitalWrite(blueRGB, LOW);
  }
  else{
    digitalWrite(redRGB, HIGH);
    digitalWrite(greenRGB, LOW);
    digitalWrite(blueRGB, LOW);
  }
     
//check button - do some stuff

  //debounce
  int reading = digitalRead(buttonPin);

  if (reading != lastButtonState) {
    lastDebounceTime = loopTime;
  }

  //button has changed
  if ((loopTime - lastDebounceTime) > debounceDelay) {

    if (reading != buttonState) {
    //record the click  
      stateCount++;
      timeOutTimer = loopTime;
      buttonState = reading;
    
    //reset the button time out
      buttonPressStart = loopTime;
    
    //reset first press timer
      if(stateCount == 1){
          firstPressTime = loopTime;
      }
    }
  }

  lastButtonState = reading;



//check button state count and activate oven 

  //not pressed, everything is off
  if (stateCount == 0 && buttonState == LOW){
    ovenOn = LOW;
    pulseMode = LOW;
  }
  
  //first press, turn oven on normally
  if(stateCount == 1 && buttonState == HIGH){
    ovenOn = HIGH;
    pulseMode = LOW;
  }
  
  //something is amiss, reset
  if(stateCount == 1 && buttonState == LOW){
    ovenOn = LOW;
    pulseMode = LOW;
    stateCount = 0;
  }
  
  //released button after first press, turn oven off
  if (stateCount == 2 && buttonState == LOW){
    ovenOn = LOW;
    pulseMode = LOW;
  }
  
  //something is amiss, reset
  if(stateCount == 2 && buttonState == HIGH){
    ovenOn = LOW;
    pulseMode = LOW;
    stateCount = 0;
  }
  
  //second press of double click, enter pulse mode
  if (stateCount == 3 && buttonState == HIGH){
    pulseMode = HIGH;
  }
  
  //something is amiss, reset
  if(stateCount == 3 && buttonState == LOW){
    ovenOn = LOW;
    pulseMode = LOW;
    stateCount = 0;
  
  }
  
  //more than the double click, reset the counter
  if(stateCount >= 4){
    stateCount = 0;
  }
  
  
  //timer for double click
  if(loopTime - firstPressTime > buttonTimer){
    stateCount = 0;
  }
  
  //timer to reset stateCount  in case of errors
  if((loopTime - timeOutTimer) > timeOut && buttonState == LOW){
    stateCount = 0;
  }
  
  //if the button is not pressed set oven to off
  if(buttonState == LOW){
    ovenOn = LOW;
    pulseMode = LOW;
  }
  
  
  //if the temperature is above the cutoff, set the oven to off
  if(tempC >= tempCutOff){
    ovenOn = LOW;
    pulseMode = LOW;
  }
  
  
  // on off switch for oven
  if(ovenOn == HIGH){
    digitalWrite(intLED, HIGH);
    digitalWrite(LED1, HIGH);
    digitalWrite(triggerPin, HIGH);
  }
  
  if(pulseMode == HIGH){

    if(loopTime - pulseOvenStart < pulseOvenTime){
      digitalWrite(intLED, HIGH);
      digitalWrite(LED1, HIGH);
      digitalWrite(triggerPin, HIGH);  
    }
    else{
      digitalWrite(intLED, LOW);
      digitalWrite(LED1, LOW);
      digitalWrite(triggerPin, LOW);
    }
      
    if (loopTime - pulseOvenStart > pulseOvenTime*2){
      pulseOvenStart = loopTime;
    }
    
  }
  
  if(ovenOn == LOW && pulseMode == LOW){
  
    digitalWrite(intLED, LOW);
    digitalWrite(LED1, LOW);
    digitalWrite(triggerPin, LOW);
  
  }


}




//returns temperature in celcius from TMP36 sensor
int getTemp(){
    
 int tempReading = analogRead(tempPin); 
 
 // converting to voltage
 double voltage = tempReading * 5.0;
 voltage /= 1024.0; 

 // print the temperature
 double tempCdoub = (voltage - 0.5) * 100 ;  
 
 int tempCint = tempCdoub;
 
return tempCint;

}


//returns the voltage from the voltage sensor
float getVoltage(){

    int data = 0;
    float V = 0.0;
    float R1 = 47000.0;  
    float R2 = 22000.0; 

    data = analogRead(voltSensorPin);
    V = (data * 5.0) / 1024.0; 
    
return(V / (R2 / (R1 + R2))); 

}

Footer

QUICK LINKS

Ready Baked

Rechargeable

Mains

Roll Your Own

VapOven Kits

Tools and components

Videos, diagrams and guides

Useful information

Shipping and packaging

Warranty and returns

About our batteries

Get in touch

[email protected]

Contact us

© 2025 VapOven · Baked by Blackbird

This website uses cookies to improve your experience. We'll assume you're ok with this, because who doesn't like cookies, but you can opt-out if you wish. Cookie settingsOK
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these cookies, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT