Sketch for the IR transmitter used here
Simply paste below into the arduino sketch window.
/* This is the beam pattern for the Team Barnato timing beacon. Use at own risk and no warranties are given.
in Micro Seconds
On - 468 uS
Off - 1200 uS
On - 468 uS
Off - 1200 uS
On - 468 uS
Off - 6000 uS */
int IRledPin = 3; // LED connected to digital pin 3
int powerLed = 13; //Power LED is connected to pin 13
void setup() {
// initialize the IR digital pin as an output:
pinMode(IRledPin, OUTPUT);
pinMode(powerLed, OUTPUT);
digitalWrite(powerLed, HIGH);
delay(2000);
digitalWrite(powerLed, LOW);
}
void loop()
{
pulseIR(468);
delayMicroseconds(1200);
pulseIR(468);
delayMicroseconds(1200);
pulseIR(468);
delayMicroseconds(6000);
}
// This procedure sends a 38KHz pulse to the IRledPin
// for a certain # of microseconds.
void pulseIR(long microsecs) {
// we'll count down from the number of microseconds we are told to wait
cli(); // this turns off any background interrupts
while (microsecs > 0) {
// 38 kHz is about 26 microseconds - to give 50% duty cycle 13 microseconds high and 13 microseconds low
digitalWrite(IRledPin, HIGH); // this takes about 3 microseconds to happen
delayMicroseconds(10); // hang out for 10 microseconds
digitalWrite(IRledPin, LOW); // this also takes about 3 microseconds
delayMicroseconds(10); // hang out for 10 microseconds
// so 26 microseconds altogether
microsecs -= 26;
}
sei(); // this turns them back on
}
No comments:
Post a Comment