Hello,
I am new in attiny 85. I want to create a attiny85 based transmitter. I compiled the code in arduino UNO it works fine. but when I compiled it in attiny85 it does not send any IR signal. I checked it several time. the same hardware settings worked in arduino but not in attiny85. with the same core and library IR receive work perfectly in attiny85. But irsend does not react. please see my code. Also thanks in advance for your help.
transmitter code:
#include <IRremote.h> #include <IRremoteInt.h>
IRsend irsend;
// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 0; // the number of the pushbutton pin
const int buttonPin1 = 1;
const int buttonPin2 = 3; // the number of the pushbutton pin
const int buttonPin3 = 4;
const int ledPin = 2; // the number of the LED pin
// variables will change:
int buttonState = 0;
int buttonState1 = 0;
int buttonState2 = 0;
int buttonState3 = 0; // variable for reading the pushbutton status
void setup() {
// initialize the LED pin as an output:
// Serial.begin(9600);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);
pinMode(ledPin, OUTPUT);
}
void loop(){
// read the state of the pushbutton value:
buttonState1 = digitalRead(buttonPin1);
if (buttonState1 == HIGH) {
// turn LED on:
// for (int i = 0; i < 3; i++)
irsend.sendNEC(0x40BD48B7, 32); // MY TV chan-up code
delay(40);
}
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
// for (int i = 0; i < 1; i++)
irsend.sendNEC(0x40BDC837, 32); // MY TV Chan-down code
delay(40);
}
buttonState2 = digitalRead(buttonPin2);
if (buttonState2 == HIGH) {
// for (int i = 0; i < 1; i++)
irsend.sendNEC(0x40BD8877, 32); // MY TV vol-up code
delay(40);
}
buttonState3 = digitalRead(buttonPin3);
if (buttonState3 == HIGH) {
// for (int i = 0; i < 1; i++)
irsend.sendNEC(0x40BD08F7, 32); // MY TV vol-down code
delay(40);
}
}
Thank you for your reply. But When I upload the code into arduino I changed the IR LED pin to PWM3. I already mentioned in arduino it works. but in attiny85 its not working. is there any way?
I am currently working with an ATtiny24 and being new to the chip I realized it's common to make mistakes identifying the pins and how they are mapped in the Arduino IDE. I don't know anything about these IR libraries but groundfungus is right I believe if you look at the irsend.sendNEC(0x40BD48B7, 32) function itself, it doesn't seem to be taking any information about which port the PWN will be sent through to the IR LED so may be it's defined by default to be at pin 3 which is the physical pin 2 on the tiny85. May be you can connect the IR to digital pin 3 (or physical pin 2 as per the below diagram) and initialize any other pin as the button input instead of 3 and then try the code?
Thanks every one. Finally I solved my problem. If I use pin1 (attiny85 physical pin 6) then pin 4 is not working. I use another library and it works fine. but I get two different code while pressing one push button also there is no match which I want to send. Then I change the code in receiver. So it is working now.