Just another update. I will get this finished some day...
I want this to be a "stand alone" project so I started fooling with ATtiny 85's. Thanks to the kind and patient folks here I've made some progress on that front.
I believe I may be able to run this project with an ATtiny 85. I found this code which runs well on it:
void setup() { //nothing to do in setup
}
byte t = 0; //used for looping between LED's in a knight rider kind of fashion
void loop() {
for (t = 0; t < 10; t++) {
charliePlex(t); //switch on LED number T
delay(75); // Wait a bit
}
for (t = 9; t >= 0; t--) { // Reverse the run
charliePlex(t); // switch on LED number T
delay(60); // delay a bit
}
charliePlex(10); //switch off all LEDs I only had 9, so if you try to switch on any
//bigger number, they would all be off.
delay(500); //big delay before we do it all over again
}
void charliePlex(byte i) { // This function switches on one of the LED's. Due to the way I
// laid out my circuit, the pins are not exactly in a logical order,
// but if you understand the concept, it's easy to tune it for your circuit.
for (int t = 0; t < 4; t++) pinMode(t, INPUT); // I used IO ports 0-4. the ATTINY85 only has 5
//(or 6 if you sacrifice reset) GPIO's. This loop will switch
// off all the LED's, because it sets the IO ports to input
// (high impedance) mode.
switch (i) { //decide which LED we want to switch on
case 0: charlieSwitch(2, 0); //The first LED is wired from Pin 2 to Pin 0
break;
case 1: charlieSwitch(0, 2); // the second LED is the reverse of the LED above
break;
case 2: charlieSwitch(1, 0);
break;
case 3: charlieSwitch(0, 1);
break;
case 4: charlieSwitch(1, 2);
break;
case 5: charlieSwitch(2, 1);
break;
case 6: charlieSwitch(3, 2);
break;
case 7: charlieSwitch(2, 3);
break;
case 8: charlieSwitch(3, 1);
break;
}
}
void charlieSwitch(byte pin1, byte pin2) { //This function merely sets the ports as output,
// and drives the first one HIGH and the Second one LOW
pinMode(pin1, OUTPUT);
pinMode(pin2, OUTPUT);
digitalWrite(pin1, HIGH);
digitalWrite(pin2, LOW);
}
It uses 4 pins to charlieplex 9 LED's leaving 1 pin for input. I'm hoping I can use the last pin for input from the HE sensor but I was wondering if I may need an external clock like a crystal to get it working. It's not going to be a high precision instrument so maybe the chip alone will do it?
Any input would be most welcome!