I try to make a 38 KHz carrier IR remote control frequency using delay function. When I press the key named "tasto1" the remote could send from ir led the carrier but I don't see nothing on the ocilloscope.The remote control have a ATtiny 2313V mcu and I wrote the code in avr-c using avr-gcc compiler. Is there something wrong with this code?:
#include <avr/io.h>
#define F_CPU 4000000UL
#include <util/delay.h>
#include <avr/pgmspace.h>
#include <avr/interrupt.h>
#include <avr/sleep.h>
#include <util/atomic.h>
volatile uint8_t tasto1= !(PINB6 & PIND2);
int main()
{
DDRD = 0x01;
PORTD = 0x00; // LED on PD0 output low (sink) for hardware modulator
while (1) {
if (tasto1==0){ //enable IR driver
PORTD &= ~(1 << PD0);
_delay_us(18);
PORTD |= (1 << PD0);
_delay_us(8);
}
else { DDRD=0x00;}
}
}
When I compile and upload the hex code on the mcu I haven't errors. I must use the delay function solution because the dedicated pins to make timers are mapped (wired) to be used like keys.