I've removed the resistors from the LEDs to make it smaller. The 1 and 2 on the left are outputs from the arduino (which supplies the VCC and ground).
These 1 and 2 are HIGH or LOW and I want the leds to turn on according to this table:
┌───────┬────────────────────┐
│ INPUT │ OUTPUT │
├───┬───┼──────┬──────┬──────┤
│ A │ B │ Led1 │ Led2 │ Led3 │
├───┼───┼──────┼──────┼──────┤
│ 0 │ 0 │ 1 │ 0 │ 0 │
│ 1 │ 0 │ 0 │ 1 │ 0 │
│ 0 │ 1 │ 0 │ 0 │ 1 │
│ 1 │ 1 │ 1 │ 0 │ 0 │
└───┴───┴──────┴──────┴──────┘
And this is the code I am using with the ATTiny85
const int pinA = PB3;
const int pinB = PB4;
const int pinOut1 = PB2;
const int pinOut2 = PB1;
const int pinOut3 = PB0;
void setup() {
pinMode(pinA, INPUT);
pinMode(pinB, INPUT);
pinMode(pinOut1, OUTPUT);
pinMode(pinOut2, OUTPUT);
pinMode(pinOut3, OUTPUT);
int a = digitalRead(pinA);
int b = digitalRead(pinB);
if (a == b) {
digitalWrite(pinOut3, HIGH);
}
else if (a == HIGH) {
digitalWrite(pinOut1, HIGH);
}
else {
digitalWrite(pinOut2, HIGH);
}
}
With this set up, I get this output:
┌───────┬────────────────────┐
│ INPUT │ OUTPUT │
├───┬───┼──────┬──────┬──────┤
│ A │ B │ Led1 │ Led2 │ Led3 │
├───┼───┼──────┼──────┼──────┤
│ 0 │ 0 │ 1 │ 0 │ 0 │
│ 1 │ 0 │ 0 │ 1 │ 0 │
│ 0 │ 1 │ 1 │ 0 │ 0 │ <- See the difference
│ 1 │ 1 │ 1 │ 0 │ 0 │
└───┴───┴──────┴──────┴──────┘
I think it has something to do with the fact that the ATTiny gets powered on if you supply 5v to one of the input pins too and not to VCC.
And yes, I keep restarting the board (by pulling out the VCC pin and seeing the led turn off).
I've also tried connecting A and B to VCC and ground both in all possible positions. Here I noticed that connecting A (or B) to 5v (of the arduino) while VCC is not connected, the board will turn on.
I hope this is enough info.