Pololu Robotics & Electronics
Menu
My account Comments or questions? About Pololu Contact Ordering information Distributors

Pololu Forum

ATtiny 13A IR remote

Hi, I am new to the hobbyist field of electronics and microcontrollers. I began researching the field about one year ago, and have been working on several projects over the summer time. One of my projects is developing a cheap, minimalist IR remote for my Nikon D50 DSLR. My goal is to shrink my code enough so that I can run it on an ATTINY13A-PU, which has 1 kb of program space, 64 x 8 bytes of RAM, and 64 x 8 bytes of EEPROM. The datasheet for this microcontroller can be found on Digikey. The problem is, I can only get the code down to 1050 bytes, so I wanted to reach out to the Pololu community to see if anyone can help me with this. My code is as follows:

void setup()   {                
  
  pinMode(13, OUTPUT);   
  }
 
void loop()                     
{
  
  pulseIR(2080);
  delay(27);
  pulseIR(440);
  delayMicroseconds(1500);
  pulseIR(460);
  delayMicroseconds(3440);
  pulseIR(480);
 
  delay(60*1000);  
}
 

void pulseIR(long microsecs) {
    
  while (microsecs > 0) {
   digitalWrite(13, HIGH);  
   delayMicroseconds(10);        
   digitalWrite(13, LOW);   
   delayMicroseconds(10);
 
   // so 26 microseconds altogether
   microsecs -= 26;
  }
 }

I could also use help with figuring out how to upload programs to the ATTiny 13A and an ATMega 48pv using either an Arduino Uno R3 or a V2.1 pololu programmer.

Hello.

To make your program smaller, you can write directly to the AVR registers instead of using the Arduino pinMode and digitalWrite functions and change the data type for the argument to pulseIR to be an int16_t, not a long. You can also try replacing all your delays with calls to _delay_us and delay_ms functions provided by avr-libc, which might reduce the program size.

With regards to programming your AVR boards using the Pololu USB AVR Programmer v2.1, if you have not done so already, I recommend looking at the AVR programmer user’s guide for details on how to use the AVR programmer.

- Amanda

Thank you for responding. I will try doing this when I get the chance.