• 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 – Variable Power

Variable Power

This is a more advanced program for your VapOven Arduino Shield, it enables variable power at the turn of a dial

This code enables the potentiometer that’s included in the kit. The dial turns up the clouds… At it’s lowest setting you’ll get light flavoursome terpy hits, turn up the dial and you’ll get huge clouds

Simply copy and paste the code below into the Arduino IDE and upload to your VapOven Arduino Shield to add variable power 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.

VapOven DIY kits

/*
 * Advanced code for the VapOven Arduino Shield
 * 
 *  **ADJUSTABLE HEATING***
 *  
 *  Potentiometer adjusts heat by altering the pulse heating duty cycle.
 * 
 * 
 * turns on the IH module and light up LED1 when the trigger button is pressed

 * 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;

bool buttonState;  //variable for the button press

bool ovenOn = LOW;  //the main oven on / off variable

int tempC; //temperature from TMP36 sensor
int tempCutOff = 60;  //temperature in Centigrade to stop IH activating

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


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



float loopTime;

int potValue; // value returned from potentiometer



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);

}

void loop() {

  loopTime = millis();
   
//check the temperature
  tempC = getTemp();
  
//check the battery voltage (if the button isn't pressed)
  if(ovenOn == 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);
  }
    
//read the potentiometer value
  potValue = analogRead(potPin);

  //set pulse time to pot value
  pulseFactor = map(potValue, 0, 1023, 0, 200);

//check if the button is pressed
  buttonState = digitalRead(buttonPin);
  
//if the button is pressed set oven to on, else set it to off
  if(buttonState == HIGH)  ovenOn = HIGH;
  else  ovenOn = LOW;
  
//if the temperature is above the cutoff, set the oven to off
  if(tempC >= tempCutOff){
    ovenOn = LOW;
  }


// on off switch for oven
  if(ovenOn == HIGH){

//if pot is turned all the way down, heat at full power
    if(pulseFactor < 5){
      digitalWrite(intLED, HIGH);
      digitalWrite(LED1, HIGH);
      digitalWrite(triggerPin, HIGH);
    }
    
//pulse to adjust the heating based on the pot knob reading
    else{
        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 + ((pulseOvenTime/100)*pulseFactor)){
          pulseOvenStart = loopTime;
        }
  }
}
  else{
    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; 

 // output the temperature
 double tempCdoub = (voltage - 0.5) * 100 ;  //converting from 10 mv per degree wit 500 mV offset
                                               //to degrees ((voltage - 500mV) times 100)
 //parse from double to int
 int tempCint = tempCdoub;
 
return tempCint;

}


//returns the battery voltage
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