Inital Commit
This commit is contained in:
41
src/main.cpp
Normal file
41
src/main.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/delay.h>
|
||||
|
||||
#define CODE '0b000000000001'
|
||||
#define BIT_LENGTH 100
|
||||
|
||||
void carrier(int BlastTime) {
|
||||
for(int i=0; i<(BlastTime / 2); i++)
|
||||
{
|
||||
PORTB |= (1 << 0x04);
|
||||
_delay_ms(BIT_LENGTH);
|
||||
PORTB &= ~(1 << 0x04);
|
||||
_delay_ms(BIT_LENGTH);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void sendBlast(void) {
|
||||
carrier(10);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
//PB1 Button (pin 6); PB4 LED (pin 3)
|
||||
|
||||
DDRB |= (1 << 0x04); // Set PB4 Output
|
||||
PORTB |= (1 << 0x01); //Set PB1 high
|
||||
|
||||
while(true)
|
||||
{
|
||||
if ((PINB & (1 << 0x01)) == 0)
|
||||
{
|
||||
sendBlast();
|
||||
}
|
||||
else {
|
||||
PORTB &= ~(1 << 0x04);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user