How do I program an Arduino to be used as an interrupter in a Solid State Tesla Coil?
5
answers
|
Answer it!
|
int potPin = 14;
int potVal = 0;
int outPin = 11;
int pulse_length = 0;
int 555_pin = 4;
void setup() {
/*
//You can change the PWM frequency of pin 11 here by changing the 0x01 setting
// check http://www.arduino.cc/playground/Main/TimerPWMCheatsheet for more
// uncomment the below line to change the frequency from 488Hz, to 32kHz
//TCCR2B = TCCR2B & 0b11111000 | 0x01Serial.begin(9600);
pinMode(potPin, INPUT);
pinMode(outPin, OUTPUT);
pinMode(555_pin, INPUT);
}
void loop() {
potVal = analogRead(potPin) / 4;
/*this will return the length in Microseconds that the pulse is HIGH on digital pin 4 (with a timeout of 1000 microseconds) and store the pulse in variable "pulse_length", you do with it what you want from there:
*/
pulse_length = pulseIn(555_pin, HIGH, 1000)
analogWrite(outPin, potVal);
Serial.print(" potVal: ");
Serial.print(potVal);
Serial.println(" ");
}
Steve
Atmegas ("arduinos") are not a processor family I have worked with, so I can't give you any specific code to help, but start by looking at the PWM modes the thing's internal timers offer. You can program the basic frequency of the PWM, and modulate the duty cycle - in fact the atmegas have 6 channels of PWM which can all be locked together in phase.
Steve
![]() |
































