On Sep 4, 11:38 am, Michael Nicholls <nicholls...@googlemail.com
> Thanks G.
> Where would I connect a pot so that it acts as a volume control
One end to ground, the other end to an Arduino pin, and the 'wiper' to
the input of the LM386.
> and what value pot would be best?
I'm not sure.
I think 1K would be a reasonable compromise (low-impedance into the
amplifier, and high impedance on the Arduino pin).
Thinking about it, it'd be sensible to AC couple the the amplifier to
the speaker with a capacitor (in series). I think that might be in the
Also, it'd make sense to use a capacitor on the amplifier input as a
low-pass filter (so the very fast transitions from the PWM get
reduced). A capacitor of around 100nF sounds about the right ball-
> Also would I need a log pot for volume?
That would be better, but for experiments, anything you can find. I'd
use a cheap preset until I'd understood how well it works. Presets are
and less tempting to twiddle once you've got it about right :-)
> I think by input ones I meant shift registers that would allow me to
> read data in, but from your explanation I can see I would use a
> Parallel In - Serial Out to allow me to read a bank of switches ;-)
If you google for PISO or SIPO "shift register" "8-bit" you'll find
> Ultimately I was thinking of maybe going for two banks of 16 LEDS. One
> bank that reflects the state of the switch associated with it and one
> bank that shows the position of the currently playing 'note'.
Yes. I was thinking along similar lines. That's why I suggested you
could parallel up the clocks from one pin, to save pins.
You can also daisy-chain the shift registers outputs to inputs.
(double check the datasheet to make sure the serial-data-out becomes
stable on the opposite edge of the clock to serial-data-input - they
should work this way, I'm just a bit careful).
> You can get push buttons that have LED's under can't you?
> Was maybe
> thinking that pressing a switch might toggle its state and illuminate
> it, but can you read a push button like that quickly enough through
> shift registers?
Well, I haven't timed it for a while, so I may be mis-remembering, but
not by more than 2x.
My recollection is I could load a shift register to change the state
of 6 LEDs in much less than 10uSec (i.e. 100,000 times/second), and
listening to switches would be a similar rate.
I wasn't using digitalWrite, but going 'straight to the pin' ( I was
concerned to do this reasonably quickly)
My other experiences are digitalWrite/digitalRead is about 4x-10x
slower than manipulating pins 'raw' (variation depends on a couple of
Now I may be mis-remembering, and it is *much* less than 10uSecs.
This is so fast that you probably don't need to worry.
You may need to scan switches several times, several milli-seconds
apart, to see if there is switch 'bounce', but you'd have that problem
if switches were directly into an Arduino anyway.
> Can you then trigger the associated LED quick enough
> through a shift register?
If we are talking human-scale-time, definitely.
The eye is amazingly sensitive to light, so a brief (under a milli-
second) flash will register, but conversely, a many milliseconds early
or late doesn't seem to matter (to my Human-World interface, or
> By quick enough I mean so it looks like it
> lights up when you press it and turns off when you press it again?
I believe yes.
I notice 100mSec delays, and don't seem to notice sub 10 mSec delays
at all, so I would expect it could probably be done 100-1000x faster
than I can perceive.