From 08c1370b456079c0f9d5e41ec92809627fa11431 Mon Sep 17 00:00:00 2001 From: Dan Date: Tue, 13 Sep 2022 02:28:49 -0400 Subject: [PATCH] switched bit to long. started speeding things up. working on code timing. Fixed the bit shift in the for loop. --- src/main.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 7fc7bba..d60b4f3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,14 +3,14 @@ #include //32 bit code -int code = 0b11111111100000000111111011100001; +long code = 0b11111111100000000111111011100001; //length of each bit -#define BIT_LENGTH 10 +#define BIT_LENGTH 1 //Generates the carrier requency for the supplied timeframe void carrier(int BlastTime) { - for(int i=0; i<(BlastTime / 2); i++) + for(int i=0; i<(BlastTime); i++) { PORTB |= (1 << 0x04); _delay_ms(BIT_LENGTH); @@ -29,9 +29,9 @@ int sendShort(void){ // send '0/ bit int sendLong(void){ - _delay_ms(BIT_LENGTH); + _delay_ms(BIT_LENGTH*2); carrier(BIT_LENGTH); - _delay_ms(BIT_LENGTH); + _delay_ms(BIT_LENGTH*2); return 0; } @@ -42,7 +42,7 @@ void sendBlast(void) { //start bit sendShort(); - _delay_ms(BIT_LENGTH); + _delay_ms(BIT_LENGTH*3); for(int i=0; i<32; i++){ if (code &0x80000000){ @@ -50,8 +50,8 @@ void sendBlast(void) { } else{ sendLong(); - code<<=1; } + code<<=1; } //stop bit