I'm seeing some pretty weird behaviour out of the tiny. I've cut my ATtiny code back to simply modulating pin 0 LOW, HIGH, LOW, HIGH, LOW, HIGH etc 48 times, holding each state for 500 microseconds and looking at what I get back in the UNO. So far I can't match the ATtiny output with the input I see on the UNO.
I recently did something similar to what you are doing but I did do it successfully. Hopefully i can explain it well enough now.
What I did was create a High check on the Attiny85, where the microcontroller would look for the receiving pin to stay high for an x amount of microseconds and if it does an LED will blink to show it was successful. Since the arduino UNO is easier to program I would then create a program to move the transmitter pin high for as short of a period as I can.
I then did a low check on the attiny using the same process as i did with the high check. First program the attiny and then change the delay times on the arduino uno. You can have as many outcomes as you want with this. The code i used is posted below.
It may take some thinking and time to build the program for whatever your using it for.Hope my process somewhat helped
// attiny code built to carry out 2 commands based on signal recieved
int g=0;
int t;
// 2 rf module
// 1 light 1
// 0 piezo buzzer
// 3 led 2
void setup(){
pinMode(2,INPUT);
pinMode(1,OUTPUT);
pinMode(0,OUTPUT);
for (int i=0;i<5;i++){
digitalWrite(1,HIGH);
delay(20);
digitalWrite(1,LOW);
delay(10);
}
}
void loop(){
if (digitalRead(2)==HIGH){// high check
g=1;
for (int i=0;i<8;i++){
delayMicroseconds(58);
if (digitalRead(2)==LOW){
g=0; i=8;}// if it drops low stop
}
if (g==1){
delayMicroseconds(250);
if (digitalRead(2)==LOW){// low check
g=1;}
else{g=0;} // did not pass check
}
t=0;
if (g==1){
for (int i=0;i<2;i++){//last high check to choose option
delayMicroseconds(450);
if(digitalRead(2)==HIGH){
t=t+1;}
}
if(t==1){ // command 1
for(int i=0;i<7;i++){
for (int p=0;p<5000;p++){
digitalWrite(0,HIGH);
delayMicroseconds(5);
digitalWrite(0,LOW);
delayMicroseconds(5);
}
digitalWrite(1,HIGH);
delay(40);
digitalWrite(1,LOW);
}
}else if(t==2){// command 2
for (int i=0;i<20;i++){
digitalWrite(1,HIGH);
delay(20);
digitalWrite(1,LOW);
delay(10);
}
}
}
}
}
I think this is the program that matches up with the receiving program... my computer isn't to organized, Sorry
// arduino uno program
char input;
void setup(){
pinMode(2,OUTPUT);
pinMode(13,OUTPUT);
Serial.begin(9600);
}
void loop(){
if (Serial.available() > 0){
char input = (char) Serial.read();
if ((char)input == '1'){
digitalWrite(13,HIGH);// light on
digitalWrite(2,HIGH);//high check
delayMicroseconds(5000);
digitalWrite(2,LOW);//low check
delayMicroseconds(1250);
digitalWrite(2,HIGH); //high check
delayMicroseconds(5000);
digitalWrite(2,LOW);
digitalWrite(13,LOW);// light off
delay(500);
Serial.println("Option 1");
}else if ((char)input == '2'){
digitalWrite(13,HIGH);
digitalWrite(2,HIGH);
delayMicroseconds(5000);
digitalWrite(2,LOW);
delayMicroseconds(1250);
digitalWrite(2,HIGH);
delayMicroseconds(10000);
digitalWrite(2,LOW);
digitalWrite(13,LOW);
delay(500);
Serial.println("Option 2");
}else if ((char)input == '3'){
digitalWrite(13,HIGH);
digitalWrite(2,HIGH);
delayMicroseconds(5000);
digitalWrite(2,LOW);
delayMicroseconds(1250);
digitalWrite(2,HIGH);
delayMicroseconds(15000);
digitalWrite(2,LOW);
digitalWrite(13,LOW);
delay(500);
Serial.println("Option 3");
}else if ((char)input == '4'){
digitalWrite(13,HIGH);
digitalWrite(2,HIGH);
delayMicroseconds(5000);
digitalWrite(2,LOW);
delayMicroseconds(1250);
digitalWrite(2,HIGH);
delayMicroseconds(20000);
digitalWrite(2,LOW);
digitalWrite(13,LOW);
delay(500);
Serial.println("Option 4");
}else if ((char)input == '5'){
digitalWrite(13,HIGH);
digitalWrite(2,HIGH);
delayMicroseconds(5000);
digitalWrite(2,LOW);
delayMicroseconds(1250);
digitalWrite(2,HIGH);
delayMicroseconds(25000);
digitalWrite(2,LOW);
digitalWrite(13,LOW);
delay(500);
Serial.println("Option 5");
}else if ((char)input == '6'){
digitalWrite(13,HIGH);
digitalWrite(2,HIGH);
delayMicroseconds(5000);
digitalWrite(2,LOW);
delayMicroseconds(1250);
digitalWrite(2,HIGH);
delayMicroseconds(30000);
digitalWrite(2,LOW);
digitalWrite(13,LOW);
delay(500);
Serial.println("Option 6");
}
}
}