/*
* Program to build a stroboscoop to trim the speed of a record player.
* White led anode via 100 ohm to Vcc, kathode to drain of BS170, Gate of BS170 to PB2/OC1B
* pulse frequency = 100Hz
* pulse duty cycle = 25%
*/
#define LED_WHITE 10 // PB2/OC1B
void setup()
{
pinMode(LED_WHITE,OUTPUT);
/*
* init timer 1
* - prescaler = /64 --> 16 MHz --> 250 kHz
* - phase and frequency correct --> 125 kHz
* - counts to 1250 for 100 Hz
* - OCR1B set to 312 for 25% duty cycle
*
* CS1x = 011 -- devide by 64
* WGM1x = 1000 -- Phase and frequency correct PWM, counter endvalue in ICR1
*/
TCCR1A = (1 << COM1A1) | (1 << COM1B1); // WGM1x = xx00; COM1ax = 10; COM1bx = 10
TCCR1B = (1 << CS10) | (1 << CS11) | (1 << WGM13); // WGM1x = 10xx; CS1x = 011
ICR1 = 1249; // 1250 - 1
OCR1B = 312;
return;
}
/*
* nothing to do here
*/
void loop()
{
return;
}