i tried a different types of ic's so i was wondering if there is any programming methods i could use to make it shorter because all i can do is digitalwrite
Sample IC's
74138
744051
i tried a different types of ic's so i was wondering if there is any programming methods i could use to make it shorter because all i can do is digitalwrite
Sample IC's
74138
744051
Tried different types to do what? Make what shorter? This is really not enough information.
Those 2 chip types are not really programmed - one get 3 address lines to select 1 of 8 outputs that will follow the enable line (enable low = 1 of 8 outputs low),
and the other gets 3 or 4 address lines to select which channel gets selected to connect to the main channel, (1 of 8, 1 of 16, I don't recall how many channels there are), and I think it also has an enable signal line.
in controlling the pins from high to low or vice versa. Just like shiftout method in programming the 74hc595.
Okay, so again, make what shorter?
byte SwitchPin [3] = {2, 3, 4};
byte table[][3] =
{
{LOW, LOW, LOW}, //A - 0
{LOW, LOW, HIGH}, //B - 1
{LOW, HIGH, LOW}, //C - 2
{LOW, HIGH, HIGH}, //D - 3
{HIGH, LOW, LOW}, //E - 4
{HIGH, LOW, HIGH}, //F - 5
{HIGH, HIGH, LOW}, //G - 6
{HIGH, HIGH, HIGH}, //H - 7
};
int enabler = 7; //pin3
void output() {
pinMode(enabler, OUTPUT);
int pin;
for (pin = 0; pin < sizeof (SwitchPin); pin++)
{
pinMode(SwitchPin[pin], OUTPUT);
}
}
void setup() {
Serial.begin(9600);
digitalWrite(enabler, HIGH);
output();
}
void loop () {
blink ();
}
void blink()
{
if (Serial.available () > 0 )
{
char letter = Serial.read();
if (letter >= 'A' && letter <= 'H')
{
for (int pin = 0; pin < sizeof (SwitchPin); pin++)
{
Serial.print("pin = ");
Serial.print(SwitchPin[pin]);
Serial.print(", value = ");
Serial.println(table[letter - 'A'][pin] == LOW ? "LOW" : "HIGH");
digitalWrite(SwitchPin[pin], table[letter - 'A'][pin]);
}
}
else if (letter == '1') {
digitalWrite(enabler, HIGH);
Serial.println("enabler high");
}
else if (letter == '2') {
digitalWrite(enabler, LOW);
Serial.println("enabler low");
}
else
{
Serial.println("Nothing Happens");
return;
}
Serial.println("");
}
}
here's the sample code , this manually set to blink only 1 led. how can i make i automatically blink without making an input thru the serial monitor?
is there any better way,like the shiftout method for the 74hc595.
What do you mean "automatically blink"? Do you mean repetition at some rate, on/off?
Also what do you mean, "a better way"? A better way to do what? The easiest way to drive an LED is directly from a pin... why not do that?
For a 3 to 8 decoder I suppose you could program 3 pins with timers so they are each exact multiples of each other. Then it would cycle through each binary possibility.