I am in Jr. High and pretty new to electronics but can solder and read
basic circuits. Can someone point me in the right direction for a
circuit that will use an MP3 player channel with tones (or multitones)
to advance a sequence of LEDs? This is for a school project using a
cheap MP3 player with narration. As each new point is made on audio
track A, I hope to use a track B tone to trigger the next LED in a
sequence to highlight the matching text on a display.
Do you have a seperate output for the B audio? If not, the
narration could cause state change if it inadvertantly triggers the
logic. I don't know much about mp3 players, so I don't know the
outputs.
At the end of
the audio, the file will replay and the sequence will be something
like Audio Point1 = LED1, Audio Point2 = LED2, Audio Point3 = LED3 -
Audio Point1 = LED1, Audio Point2 = LED2, etc. I would like to keep
this to three volts D.C. or less (two AA batteries). Any suggestions?
If three leds are all you are using, and you only need to light
each one individually, you need four states. This, for me, would be
most easily done using a couple flip flops and some input and output
logic.
If you are into electronics much at all, and to even think of
trying this indicates you are, it would be a great opportunity to
teach yourself a bit about digital logic since this idea is just about
perfect as a beginning sequential logic problem, as well as a
beginning combinational logic problem. If you get a book on digital
logic (I cannot recommend a good one, but hopefully someone else can),
you will learn how to draw up your state diagram, figure out
conditions for state switching and how to minimize your logic.
Let:
L0 = no LEDs on
L1 = LED #1 on only
L2 = LED #2 on only
L3 = LED #3 on only
For a basic idea, imagine that you have four logical states, each
using two bits, state 00, state 01, state 10 and state 11, and each
state triggers some logic which turns on the appropriate LED. We're
using SR flip flops here (an SR latch (or flip flop, in this case) has
two inputs, SET and RESET, if you send a logic pulse to SET, the SR
outputs a 1, or approx 5V, and if you send a logic pulse to RESET the
SR outputs a 0, or approx 0V).
So:
00 = L0, 01 = L1, 10 = L2, 11 = L3.
If you reset flip flop 1 (Q1) and reset flip flop 2 (Q2) (this means
trigger both flop flops so they both output zeroes), you get state 00
If you reset Q1 and set Q2 you get state 01
If you set Q1 and reset Q2 you get 10
If you set both Q1 and Q2 you get state 11.
Your input logic would be something like:
(I'm using ' for NOT, so Q1' means Q1 = 0 and Q1 means Q1 = 1. Q1
is the output of flip flop Q1)
(B means that the B audio has sent an appropriate signal)
If Q1' AND Q2' AND B, then RESET Q1 and SET Q2 (IE set flip flop to
state 01)
If Q1' AND Q2 AND B, then SET Q1 and RESET Q2 (now we're in state
10)
If Q1 AND Q2' AND B, then SET Q1 and SET Q2 (here we are in state
11)
If Q1 AND Q2 AND B, then RESET Q1 and RESET Q2 (back to state 00,
all LEDs off)
So you'd need four 3 input AND gates to handle all of the input
logic, as well as a couple inverters to drive the Q1' and Q2' (keep
reading, it will be explained).
This will just keep rolling through the LEDs every time your B
audio triggers the logic gates. First L0, then L1, then L2, then L3,
then L0, etc... You can figure out logic to drive any combination of
LEDs as long as you remember to have one state for each different
output.
Your output logic would be something like this:
Q1' AND Q2' = L0 (do nothing)
Q1' AND Q2 = L1
Q1 AND Q2' = L2
Q1 AND Q2 = L3
You'll have three AND gates, each one driving an LED (remember to
put a resistor in series with each LED), and a couple inverters, the
first piece of logic (Q1' AND Q2' = L0) would be unimplemented since
you just need to make sure you don't turn on any LEDs for it.
Wiring the circuit:
When you see "Q1 AND Q2 = L3" you need three wires, one wire comes
from Q1 and goes to one input of the AND gate, one wire comes from Q2
and goes to the other input of the AND gate, and one wire comes from
the output of the AND gate and goes to L3 (through a resistor, though
you could use a common cathode resistor for all the LEDs, but thats
not important for this discussion). Where it says Q1', send the Q1
output first into an inverter (a NOT gate, it takes a 0 and outputs a
1, or takes a 1 and outputs a 0) and then send the inverted output to
the AND gates. The input logic uses the same ideas, using three
inputs on each AND gate. Do not just send two inputs to a three
input AND gate, the AND gate will not output a 1 unless ALL inputs are
1s (approx 5V). You do not need a seperate NOT gate for each AND
gate, so you really only need two of the NOT gates of the six you will
get on the chip. All of the Q1' inputs into the AND gates come from
the output of the NOT gate which has Q1 as its inputs, and all of the
Q2' inputs into the AND gates come from the NOT gate which has Q2 as
its input.
You might notice that the outputs of the flip flops not only drive
the LEDs, but also create much of your input logic. Using outputs to
influence inputs is virtually universal in sequential logic (logic
where you need to go from one state to another), and is a very handy
thing.
If you want to try this out, it would take five chips: Two 74LS11
three input AND gates at three gates per chip (two unused), one
74LS279 S-R latch chip with four S-R latches (you'll use two), one
74LS08 two input AND gate chip with four gates on the chip (one
unused), and one 74LS04 inverter chip (4 unused). Some input stuff
depending on what the B audio outputs, and for output some resistors
and LEDs (and the power supply, obviously). All the chips together
shouldn't cost more than a few dollars if you order from an average
mail order house.
Other very bright people have posted circuits, and I doubt I could
do better so I'll abstain. I assume the information given above
should be enough to let you design your own schematic anyway, with
maybe some reading. Doing so would not only be educational but
probably get you an A if you show the teacher why and how it works.
Certainly this is not the lowest chip count way to solve the problem,
but it is probably the most basic way when it comes to using digital
logic (unless you want to build up the SR latches using two additional
AND gates and four of the unused NOT gates, it wouldn't change chip
count unless you used the two unused three input AND gates with one
input on each tied high, but it might confuse the issues at hand so
I'll leave it unless someone asks how to do so). Any digital circuit
which handles this problem is going to use this same basic idea
(sequential logic and four states, driven by and driving combinational
logic), merely using more complex circuitry inside each chip to lower
parts count.
Both digital and analog circuitry are very important, most designs
use some of each, but many people not in a specific program of study
tend to concentrate on analog when they are getting started (at least
this was true when I started, today it might be different).
!Caution: Soapbox Alert!
In my opinion a major reason why manufacturing is so expensive in
the USA and various computer programs (dare I say OSes) are so buggy,
is that not enough time is spent on drawing up the state diagrams of
systems and applying some basic logic analysis. I've met many
programmers who have never really applied basic logic techniques to
their programs, either they never learned it or they were never fully
impressed with the importance of logic simplification for writing
tight code. Hey, I'm guilty too! I can't count the times I've
hacked a project together thinking "This is way too simple to mess
around.", but that thinking often leads to more complex logic using
more gates (or code) than necessary and increasing the overall cost,
not only in terms of component costs, but also in manufacturing and in
debug time and costs. This doesn't just mean a cellphone costs a bit
more, it also means people could lose their jobs if another company
makes the device cheaper. Yes, a state diagram for a large program
can be very intensive, but this is all the more reason to be sure
everything is going to work as smoothly as possible, with the tightest
possible code. Anyway, FWIW, thats my opinion, subject to change and
with no warantee of any value.
!Soapbox Alert Over!
I'd recommend spending some time on digital and learning about
basic switching logic and the related math. It's not that hard if
you have an application to apply it to, and as you go you'll learn
about boolean algebra, Karnaugh mapping, Demorgan's theorems and
combinational and sequential logic. This may sound difficult, but
its not really, and it all applies (I don't like doing math if I am
not applying it to something in the real world). Once you learn it
and use it a while, figuring out how to do this idea or any other
using various states will become second nature.
An added benefit is that if you ever decide to program computers,
at any level, knowing how to simplify logic and draw a state diagram
will make you much better at it!
Above all, have fun!