Looking to use a MCU IC ATTiny414 to modulate an IR led signal at 38Khz, pulsed at 600us on and 900us off.
Is this the general Idea?
Init the chip/timer of to 38Khz
Set the output pin High at that frequency
delay for 600us
Set the pin Low
delay for 900us
Can’t find any exact matches as suggestions to code this. So I’m trying to piece together other solutions from here and others. Need help adapting the set up (that code is for an Arduino. I have to use a ATtiny412.
// set up Timer 2 for 38khz - NEED HELP to adapt this Arduino to ATtiny414
TCCR2A = _BV (COM2A0) | _BV(WGM21); // CTC, toggle OC2A on Compare Match
TCCR2B = _BV (CS20); // No prescaler
OCR2A = 209; // compare A register value (210 * clock speed)
// = 13.125 nS , so frequency is 1 / (2 * 13.125) = 38095
} // end of setup
void loop() {
//the IR receiver is expecting “on” 600us and “off” 900us
digitalWrite(IRLED, HIGH); //turn on the IR LED
delayMicroseconds(900);
digitalWrite(IRLED, LOW); //turn off the IR LED
delayMicroseconds(600);
No arduino core for that chip. All the peripherals are totally different from traditional AVRs, youll need to use atmel studio and really stufy the datasheet. Much more complicated, and not relevant for this forum becayse not supported on arduino ide.
Darn, I had bought a large number of these...but, I guess I should try another MCU IC, ATtiny or otherwise...
I'm looking to code a Microchip IC to control and pulse a whole bunch of these IR LEDs for a large interactive, art installation. The similarly large number of IR receivers need the emitters at 38 Khz, on 600us and off 900us
Dr Azzy...Since my first attempt is completely wrong....any suggestions on a cheap MCU IC and the code to get it pulsing? I am trying to stay working within Arduino
If you're looking in the ATTiny size range, any of the ones listed as supported by my ATTinyCore (see sig) would be a fine choice - they all have traditional AVR style peripherals and are supported in the Arduino IDE via my core.
The 841 is an excellent chip, with 2 of those nice 16-bit timers (like timer1 on the '328p), dual hardware serial, and so on.... but I don't have a good enough idea of what you're working with to make a definitive recommendation.
Economics wise, it might be worth considering just throwing el-cheapo pro mini clones at it - they're insanely cheap for what you get.