RESULTS!

I have been vaping off of my breadboard for about an hour now, spent all morning programming my new Arduino Nano (this is the first non-CAM programming I have done since high school) and now I have something to show for it.
here is my program:
/* First version of my Arduino Personal Vaporizer controller.
Does basically what the PWM 555 circuit on EcigF does, but with a
digital potentiometer style control built in. It has ten power steps,
and lights a dual mode LED to indicate which button is being pressed.
Also has a simple debounce timer on the up and down buttons.
*/
// pin number constants :
const int CbuttonU = 2; // the number of the up pushbutton
const int CbuttonD = 3; // the number of the down pushbutton
const int CbuttonH = 4; // the number of the hit pushbutton
const int CledU = 11; // the number of the up LED
const int CledD = 12; // the number of the down LED
const int Cfire = 13; // the number of the PWM output
// variables :
int VpowerLevel = 1; // holds the current user adj. power setting
// setup, initialize pins
void setup() {
// input pins
pinMode(CbuttonU, INPUT);
pinMode(CbuttonD, INPUT);
pinMode(CbuttonH, INPUT);
// output pins
pinMode(CledU, OUTPUT);
pinMode(CledD, OUTPUT);
pinMode(Cfire, OUTPUT);
digitalWrite(CledU, HIGH);
digitalWrite(CledD, HIGH);
}
void loop()
{
//If the hit button is pressed, basic PWM bitbang
if (digitalRead(CbuttonH)== HIGH)
{
digitalWrite(Cfire, HIGH);
delayMicroseconds((VpowerLevel * 250)+400); //ON pulse
digitalWrite(Cfire, LOW);
delayMicroseconds(1500); //OFF pulse
}
//If the up button is pressed, increase on time
if (digitalRead(CbuttonU) == HIGH)
{
if (VpowerLevel <10)
{
digitalWrite(CledU, LOW);
delay(100);
VpowerLevel = VpowerLevel + 1;
while(digitalRead(CbuttonU) == HIGH)
{
delay(1);
}
}
digitalWrite(CledU, HIGH);
}
//If the down button is pressed, decrease on time
if (digitalRead(CbuttonD) == HIGH)
{
if (VpowerLevel >1)
{
digitalWrite(CledD, LOW);
delay(100);
VpowerLevel = VpowerLevel - 1;
while(digitalRead(CbuttonD) == HIGH)
{
delay(1);
}
}
digitalWrite(CledD, HIGH);
}
}
It is pretty simple. There is an up button, a down button, a fire button, and some led's, as well as the same IRLB8748 N-channel FET that I am using in my 555 pwm mods.
The program "bitbangs" pin 13 of the arduino, which is the gate of the mosfet. This gives me access to higher kHz levels than the actual built-in pwm of the arduino, it needs to be above the human hearing range or you will hear a buzz or even a shrill whine coming from your atomizer. There are ten steps of adjustability using the up-down buttons.
My next step is to add a voltage sensing variable to everything to compensate for the battery as it drains, so you always get the same heat no matter how charged your battery is. I also want to play with sensing the atty ohms and calculating that into everything as well. Once I am happy with the program, i plan on porting it to the MSP430 launchpad so I can build a vaporizer with a $2 chip in it instead of a $25 arduino unit.
Here's the setup to build this yourself, btw:
3 tactile N/O pushbuttons
3 22k ohm resistors
1 N-channel mosfet (needs to have a 2-4v gate, higher than that and it might not trigger)
3 LED's
1 atty connector
1 2s 7.4v battery
an Arduino (duh)
Connect the battery ground to the common ground. You should be able to power the whole thing off of this battery, but you can actually power the arduino off of the usb while powering the mosfet/atty off the battery while testing.
Connect pin12 to the - of one led. Connect the + of this led to +5v pin.
Connect pin11 to the - of a different led. Connect the + of this led to +5v pin.
Connect pin13 to the + of the third led (optional) and the gate of the FET. Connect the - of the led to ground.
Connect pin 2 to one of the switches and to a 22k resistor going to ground.
Connect pin 3 to one of the switches and to a 22k resistor going to ground.
Connect pin 4 to one of the switches and to a 22k resistor going to ground.
Connect the other leg of all three switches to +5 pin.
Connect the source leg of the FET to ground.
Connect the drain leg of the FET to the atty -.
Connect the atty + to the BATTERY +. DO NOT connect this to the +5v pin.
There you have it. Now back to the grind.