I want my Attiny85 to communicate with another attiny85. one attiny should send a message to my other attiny. When he receives the correct message he should turn one led on. Just a very simple test scatch. I don't know why but the led never turns on.
Here is my code:
1st attiny85:
int clk_pin = 4,
data_pin = 3,
led = 0;
void setup() {
pinMode(clk_pin, INPUT);
pinMode(data_pin, INPUT);
pinMode(led, OUTPUT);
}
void loop() {
byte incoming = shiftIn(data_pin, clk_pin, LSBFIRST);
if (incoming == 2)
{
digitalWrite(led, HIGH);
delay(1000);
digitalWrite(led, LOW);
delay(1000);
}
}
2nd attiny:
int clk_pin = 0,
data_pin = 1;
void setup(){
pinMode(clk_pin, OUTPUT);
pinMode(data_pin, OUTPUT);
}
void loop(){
byte test = 2;
shiftOut(data_pin, clk_pin, LSBFIRST, test);
delay(5000);
}
I think there might be something wrong with my shiftIn/shiftOut command. It's actually the first time I'm using this.
Thanks for helping!