IR Transmitter Circuit With ATtiny85

Hi. I am trying to make IR transmitter circuit for TV or anything, with ATtiny85. My code works on arduino ,it sends every hex code I want. But when I load my code in attiny 85 circuit works my IR led blinks but doesnt sends my hex value. Just sending 0x000 unknown cammanded codes or sends RC5 0xXXXXX codes. I tried every think i'm tired and wasted my time for a 2 week. Can anyone help me. I just want system that will have only one button and send only one hex code. What am ı have to do for it?

my code:

#include <IRremote.h>
#define buton 2 //button input
#define IR 1 // LED output
int durum = 0;

void setup() {
pinMode(buton, INPUT);
pinMode(IR, OUTPUT);
IrSender.begin(IR);
}
void loop() {
durum = digitalRead(buton);
if (durum == 1) {
digitalWrite(IR, HIGH);

IrSender.sendNEC(0xED12BF40, 0x12,0);   
delay(1000);

}
else {
digitalWrite(IR, LOW);
}
}

1 Like

Try to make the command a const long, or 0xED12BF40UL.
is the 0x12 correct, or should it be 0x20?
Does your code work on a different controller?

Yes everthing okey with the values code works with arduino nanoe but when I upload this code in attiny85 doesnt send my hex value. Only sending 0x0000 RC-5 or unknown hex values.


0xED12BF40UL. I tried this still same thing.

To which pin is the IR transmitter LED connected?
What is the default sender pin for tiny85?

What core are you using?


this is my circuit . IR LED connects PB1 andother leg connects ground. Also i am using SPENCEKONDE core.

Maybe try pin 4 for the sender?

This from then IRremote library IRTimer.hpp file:

#elif defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
#  if !defined(IR_USE_AVR_TIMER_TINY0) && !defined(IR_USE_AVR_TIMER_TINY1)
#    if defined(ARDUINO_AVR_DIGISPARK) // tested with 16 and 8 MHz
#define IR_USE_AVR_TIMER_TINY0   // send pin = pin 1
// standard Digispark settings use timer 1 for millis() and micros()
#    else
// standard ATTinyCore settings use timer 0 for millis() and micros()
#define IR_USE_AVR_TIMER_TINY1   // send pin = pin 4
#    endif

Still same problem not working I change my LED leg this Am ı true ?
image
Pin 4 doesnt works.

I though it worth a try.

Here is a successfully tested sketch that sends what you want using an IR LED and button switch attached to a tiny85 as shown in the attached schematic. Receiver is an Uno with an IR detector.

tiny ir sender

The code:

#include <IRremote.h>

const byte butonPin = 2; //button input
const byte IRPin = 1; // LED output

void setup()
{
   // connect button to ground and input
   pinMode(butonPin, INPUT_PULLUP);

   IrSender.begin(IRPin);
}

void loop()
{
   static bool lastButtonState = HIGH;
   bool buttonState = digitalRead(butonPin);
   if (buttonState != lastButtonState)
   {
      if (buttonState == LOW)
      {
         IrSender.sendNEC(0xED12BF40, 0x12, 0);
      }
      lastButtonState = buttonState;
   }
}

I use the state change detection method to send only once for each button press. And the switch is wired to ground and the internal pull up is enabled. That is the preferred way to wire a switch.

1 Like

same result .


most of them do it with arduino uno, i try with nano, is that the problem?

No. They both use the same processor (mega328).

I thought you were working with a tiny85. I went to some trouble to wire a circuit with a tiny85, write and test the code. Did I waste my time trying to help you get the IR send to work with a tiny85?

Post a schematic of the wiring. Label the parts.

Post the receiver test code. Post the sender test code.

yes iam trying with attiny 85 just iam loading my code with arduino nano.

I have 2 arduino nano now. one of receiver other using for code load and power. I have no problem with receiver. But this attiny doesnt works.


In the photo, the 10k resistor is seen as wrongly connected, but it is not, I have a corrected version in front of me.

also i am using this shematic when upload the code


image
this is upload settings
image

I was running my tiny85 at 8MHz internal clock when I tested the code that I posted. I saw that you had 1MHz set. I bootloaded my tiny85 to 1MHz and tried the code that I posted. I get garbage on the receiver. As soon as I put the clock back to 8MHz, it was getting received properly. It looks like 1MHz is slow to get the IR protocol timing right.

okey ı'll try that also ı tried your code with arduino nano its worked now ı am gonna try with attiny. İf it will not works again probably my attiny cracked i'll change my attiny . Thnx for your help man u are the best person in the world wait my good news :smiley:

Hoping for success.

Thank you man. Its probably must work ,but doesnt works on my attiny85. I overheated my tiny85 in my first attempts, so it may have malfunctioned. I'll buy another tiny85 and make this circuit again :D. I will write here again in about 4 days. I hope all your wishes come true.

At least the IRremote library has to know the actual clock rate! You'll have to edit your boards.txt for the actual clock rate of your board.

How we'll do that ? By the way, he tried the above circuit himself and was able to send the hex code without any clock adjustment. If I'm not mistaken, it automatically sets the clock inside the IRremote library.