Trying To Get an IR Receiver to Work with an ATTiny85 Question


hello everyone.

i'm having issue using using irremote library attiny85.

i'm trying write sketch turns on led when press power button on remote control, , turns off when press again.

i know irremote library supports attiny85, because says documentation. thought maybe using wrong pin, when tried other pins, wouldn't work either. pinout diagram on sparkfun says pin 1 capable of doing pwm, need ir receiver.

i'm thinking maybe wiring wrong, or has "timers" column in irremote documentation says "tiny0", under attiny85 row. i'm not sure means. possibility i'm not starting ir receiver in setup() method.

also, i'm using tiny avr programmer upload code attiny85.
(www.sparkfun.com/products/11801)


anyway, here code (i haven't put default in case statement yet):



code: [select]
#include <irremote.h>


#define num_buttons 1

 
const uint16_t button_power = 0xffc03f;

boolean ledenable = 0; // start led off.

int recv_pin = 1;

int led_pin = 0;
irrecv irrecv(recv_pin);

decode_results results; // store our ir received codes
uint16_t lastcode = 0; // keeps track of last code rx'd


 
void setup()
{
 
   irrecv.enableirin(); // start receiver
   pinmode(led_pin, output);
 

 
   

}

void loop()
{
 
 
   
   if (irrecv.decode(&results))
   {
        uint16_t resultcode = (results.value & 0xffff);

        if (resultcode == 0xffff)
          resultcode = lastcode;
        else
           lastcode = resultcode;

        switch(resultcode)
        {
             
        case button_power:
 

          if (ledenable)
          {
             digitalwrite(led_pin, low);
             ledenable = 0;
             brightness = 0;
             

          }
          else
          {
         
              ledenable = 1;
              digitalwrite(led_pin, high);
     
             
             
          }
          break;
         
        }
        irrecv.resume(); // receive next value

     
   }

}


i've attached breadboard diagram made in fritzing.


any appreciated.



thanks in advance.

for 1 thing, resistor wired in parallel led, not in series should be.


Arduino Forum > Using Arduino > Programming Questions > Trying To Get an IR Receiver to Work with an ATTiny85 Question


arduino

Comments

Popular posts from this blog

Flip address is out of range arduino uno r3

Arduino Uno not uploading

Indesign and MathType fonts