Languages

Répondre au commentaire

infrared imitter (ver 1)

/* -----------------------------------------------------------------------
* Title: Infraled imitter
* Author: Samuel and Sofian Audry ( http://accrochages.drone.ws/ )
* Date: 25.12.2007
* Hardware: ATtiny13
* Software: WinAVR 20060421
-----------------------------------------------------------------------*/

#define F_CPU 9600000UL

#include
#include

#define LED_INFRA PB0

int i;
volatile int Data;
int counter1;

void init()
{

for (i = 0 ; i < 400 ; i ++)
{

PORTB ^= (1 << LED_INFRA);
_delay_us (13);
}

PORTB |= (1 << LED_INFRA);
_delay_ms (1);

}

void on()
{
for (i = 0 ; i < 50 ; i ++)
{

PORTB ^= (1 << LED_INFRA);
_delay_us (13);
}
}

void off ()
{
PORTB |= (1 << LED_INFRA);
_delay_ms (1);

}

void send_8bit_serial_data() // This will send data in bit 7~0, updating the clock each bit
{

unsigned char x;
int bitMask8[8] = {
0x01, // binary 00000001
0x02, // binary 00000010
0x04, // binary 00000100
0x08, // binary 00001000
0x10, // binary 00010000
0x20, // binary 00100000
0x40, // binary 01000000
0x80 // binary 10000000
};

init();

for(x = 0; x < 8; x++) // Loop through all the bits, 7...0
{
if(Data & bitMask8[x])
{
on();
}
else
{
off();
}

}
}

int main(void) {

for (;;)
{
Data = 173;

init();
send_8bit_serial_data();
_delay_ms (100);

}
return 0;

}

Répondre

By submitting this form, you accept the Mollom privacy policy.