Show Posts
Pages: 1 2 [3] 4 5 ... 86
31  Using Arduino / Project Guidance / Re: Hall effect sensor controlled LED strip on: July 07, 2014, 04:08:47 pm
Quote
My idea is to have a strip of lights that will turn on when you touch the sensor with the magnet, then turn off when you touch it again with the magnet. I don't want something that will turn off when you move the magnet away. I did my research and it looks like I need a latching hall effect sensor. Is this right?
No, you don't need a special hall effect sensor.

Your software (your Arduino "sketch")  "knows" if the LEDs are on or off.   So, you just need to change the state whenever the magnet is detected.

I recommend that you start-over without the Instructables code.    Figure-out how to detect the Hall Effect sensor and turn an LED on & off first.   And, the easiest thing to do is use the Pin-13 LED that's already on the board.   Then, maybe you can mix your new code with the Instructables code.

I'd also suggest you figure-out how to do this with a plain-old switch before adding the Hall Effect sensor (a momentary switch would best-simulate the Hall Effect sensor).   With any project, you've got to break it down into manageable parts.

The trick to what you are trying to do is an if-statment and some other logic...  In English, "If the LED is on AND the Hall Effect sensor is detected, turn it off...   If the LED is off AND the Hall Effect sensor is detected, turn it on."  Of course, the computer doesn't understand English, so you have to translate that to C++. smiley-wink

The two concepts that make programming really useful are Conditional Branching (if-statements and other similar logic that makes it possible for a computer to "make decisions")  and Loops (doing thing over-and-over, often until some condition is reached.)

I don't want to scare you , but programming is NOT easy!   Yeah, it's easy to make an LED blink, and the Arudino is a pretty good way to learn some basic programming, but a 4-year Computer Science degree is pretty-much a "programming degree".   And, professional computer programmers make more mistakes in a day than most other professionals!   Because, it ain't easy! smiley-grin    And with the the Arduino, you've got to learn at least some electronics too, and that's a whole different subject!

I suggest you read-through the  Programming Reference to get an idea of what the basic functions do.   There's not a lot to it, but you won't understand it all the first time through (and you won't remember it all) but it's still a good idea to read-through it a couple of times.    Technical subjects are like math...  You could probably read your math book in a week, but you have to read it several times and try-out the problems, and it takes a whole semester before you understand it all.

And try some of the simple examples (depending on what hardware you have) and try to understand how the code works (and how the hardware works).     I assume that you don't understand all of the code in the Instructables example, and that's OK...  Start with something simpler.

When you do start writing your own code, start with a basic "framework" program like the Blink LED example.   I almost always start with that.   Then, write one or two lines of code at at time and compile & test before continuing.   If you try to write the whole program at once, it usually won't work.   You can have one little error and the compiler might give you many error messages that don't make sense to you.   The compiler doesn't know what you are trying to do, it just knows that what you are doing doesn't make sense in C++.   

Besides making sure that there are no syntax errors (things that don't make sense in the C++ language), you can have logical errors.  In other words, the program may run but it doesn't do what you want.

One thing that's really helpful for testing & debugging is to send messages to the Serial Monitor so you can "see" what the program is doing.  For example, you can send out a message that says "start delay", and "end delay", etc.   

The biggest mistake beginning programmers make is to try and write the whole program at once.   But, it's not as easy as writing the lines in-order...  For example, if you erase the last half of an existing program, it won't compile.    You have to "build' or "develop" your program in a way that it always makes sense, especially in a way that makes sense to the compiler.

Of course, experienced programmers write more than one or two lines at at time, but they are usually working on big programs so they don't write the whole thing at once... They develop, debug, and test, one section at a time.




P.S.
You'll probably find that you need to debounce your Hall Effect sensor.    To a human, it might look like it's turning on & of "cleanly", but at some point it will be "half-on" and if the processor is reading the sensor a few million times per second, it might read 100 on/off cycles and your program may not behave as expected.   

That's one of those things you don't have to start with...  You can add the debouncing as you "develop" and debug your code.   The easiest thing is to simply add a little delay (probably a few milliseconds) each time through the loop.
32  Using Arduino / General Electronics / Re: LM2575 7.4V to 5V (i don't understand the circuit diagram) on: July 07, 2014, 02:36:52 am
The Schottky diode may be critical too.   Where I work we somehow got the wrong diode on a board with a similar circuit and the voltage regulator chip got very hot and the voltage regulation was unreliable.

I suggest you carefully study the LM2575 datasheet.
33  Using Arduino / General Electronics / Re: Circuit doesn't power off after disconnecting it's power supply on: July 06, 2014, 05:43:28 pm
Is USB connected to your computer?
34  Using Arduino / Audio / Re: Elektret Micophone on: July 06, 2014, 02:25:20 pm
I know we are overloading you with information, but a few more things -

Maybe you should try this SparkFun Electret Breakout Board.  It's got the amplifier and bias circuit built-in.   Building an amplifier with a transistor isn't easy, especially if you don't have a multimeter or oscilloscope to test & troubleshoot it.  I've always used op-amps (or other integrated circuits).     I don't  remember EVER building an analog amplifier with transistors, except maybe in school.   And, I've got an electronics degree and many years of experience.


With the capacitor in your existing circuit the DC voltage on the Arduino input is "floating" and unknown.   The AC audio waveform will ride on top of the floating DC.   With the capacitor in your circuit, put a resistor between the Arduino's analog input and ground.   (10k - 100k is fine.)

The comments in your sketch say you are connected to input A0 but you are actually reading A5.    Make sure you are reading the pin you're physically connected to.

I'm not sure if this will correct the problem of erroneous values greater than 1023, but try defining your variable before setup().
Code:
int sensorValue = 0;

Try taking the delay out completely.

If all else fails, start with the AnalogReadSerial Example complete with the pot.   When that works, replace the pot with the microphone-amplifier circuit.

Then if you wish to modify the sketch, change one or two lines of code at a time, making sure it works after every change.
35  Using Arduino / Audio / Re: Elektret Micophone on: July 06, 2014, 01:18:15 pm
Quote
have removed the Capacitor as advised, but now i get big random readings.
they vary between 5 and 4685.

also i can not surely say that any noise has influence on the numbers i see.
Hmmmm...  The ADC is only 10-bits so it only goes from 0-1023.

The readings should be "random", but you should get SOME bigger numbers with louder sounds.   

You are reading the voltage of a constantly-changing waveform...  It's like trying to read the height of a wave in the water by taking a fast reading...   You might be reading when the wave is high or when the wave is low and you don't know...  You need to take a bunch of readings and ignore everything except the peaks.   

And yes.  500ms is way too slow.   You can easily miss the peaks.

With the capacitor in the circuit, half your readings will be negative, but the Arduino can't read negative voltages and it will read zero (or near zero).  So about half of your readings will be zero.   (You are not supposed to put negative voltages into the Arduino.)

Without the capacitor, your waveform will be biased at some value (hopefully around half the ADC range, or around 512).    Silence should read around the bias-value.  Louder sounds will give bigger and smaller "random" readings.
36  Using Arduino / Project Guidance / Re: It looks like my Arduino stops for no reason on: July 06, 2014, 12:35:10 pm
Quote
Personally I never use resistor for led ...
Even if the LED or Arduino aren't permanently damaged, without the resistor you are drawing excessive current from the Arduino (exceeding it's specs) and that certainly COULD cause erratic operation and "crashing" of you sketch.

That MIGHT not be the problem, but it's a bad design and it's a good place to start.  When you are troubleshooting/debugging you never know for sure what the real problem is until the problem is solved. smiley-wink

It's easy enough to disconnect the completely LED see it that fixes the scrolling problem.
37  Using Arduino / General Electronics / Re: LED Driver PWM control on: July 06, 2014, 12:13:03 pm
Quote
Also, i'm assuming the current is less when the LEDs are not as bright, and most when full brightness?
Not exactly...    PWM switches the LED on & off faster than you can see it flashing/blinking.   The current is the same for the period of time the LED is on, and the current is zero when off.   

So, the average current is less but the peak current is the same.   And in fact, the LED isn't "dim", but your eye perceives it as dim.    (If you apply PWM to an incandescent lamp, it will be truly dim because it takes a fraction of a second for the filament to heat-up an start glowing.)


P.S.
I believe some constant-current power supplies for high-power LEDs actually do lower the DC current while dimming, even if they are "PWM controlled".


38  Using Arduino / General Electronics / Re: shift register initial state on: July 05, 2014, 04:46:43 pm
There is are OE line and a SERCLR lines.   If you choose to use these control lines, they'd normally be controlled by an Arduino output (or the output from some other logic device) and you shouldn't need a transistor.

If you hold the OE line high during power-up (or immediately after power-up) Then, you can load the desired state or clear the device before enabling the output.

Quote
and for various reasons it is essential that all outputs are off when I start up.
You have to decide what you mean by "off".  smiley-wink    If disabled (AKA "tri-stated") is "off", then OE will do it.
39  Using Arduino / Project Guidance / Re: using RST pin as digital on: July 05, 2014, 12:35:23 pm
No.   The reset pin has a particular purpose on the microcontroller chip.  Same with the power & ground pins, and clock/oscillator pins, etc.
40  Using Arduino / Project Guidance / Re: 11 band audio visualizer on: July 04, 2014, 06:09:17 pm
Quote
here is the test of the 20Hz band pass and peak detector (files attached). graph was produced with a 1Hz to 20khz sweep. Band pass definitely needs some tweaking, but this program will be a HUGE help in designing this
What you are looking for is a bandpass filter (actually, you need 11 bandpass filters).    I found this website.  The Q of the filter determines how narrow the pass-band is.

The The Active Filter Cookbook has been around since before the Internet if you can't find what you're looking for on the Internet, or if you can't understand what you're finding on the Net.

---------------------------
I've never made any frequency-related effects, but I've built a few sound activated lighting effects.    One my "tricks" is to save a reading once a second and keep a 20-second moving average and use that as my reference (a software reference).   That way, it auto-adjusts to volume changes or loud/quiet songs.    Depending on the particular effect, I use the average value or the peak value in the array.    I also automatically switch between the 1.1V & 5V ADC ranges.   (That means I have to re-scale the data in the moving average array.)    You might even want to have 11 references for lots of "action" in each band.    (That's all easy compared to the hardware.)     
41  Using Arduino / Project Guidance / Re: Arduino reading AC voltage on: July 04, 2014, 03:59:27 pm
Quote
I know its 0-5v but is this peak to peak 0-5 or rms ?
Peak.   A 5VAC RMS voltage has positive & negative peaks of about 7V.   That's 14V peak-to-peak, (or 16.8V peak-to-peak from 6VRMS)  and you are only "allowed" 5V peak-to-peak with the 2.5V bias.    Make sure to check/calibrate with a multimeter.   6V transformers tend to run a little high with a light load and the Arduino's ADC isn't as accurate as a meter.

I like steinie44's idea...  The capacitor will charge-up to the peak so you can simply read the DC.  Of course, you still need a voltage divider.  As long as the source is known to be a sine wave the relationship between RMS & peak is known and constant.  (The voltage-drop across the diodes creates a non-linearity, but line voltage is constant enough that this isn't a problem.)

You need a resistor in parallel with the capacitor so that the input doesn't "float".    100uF and 10k gives you a 1 second time constant...  It depends on how "stable" you want the readings to be and how fast you want the readings to react.     You can use a much-much shorter time-constant, or leave out the capacitor completely  if you want to "pick out" the peaks in software.

 
42  Using Arduino / Audio / Re: How to convert the MIDI to analog audio? on: July 04, 2014, 01:22:33 pm
Quote
If I want a better sound, what should I do next?
I don't know, but don't think there's an easy answer to that.   I assume if you want the best sound you need to build something that supports VSTi (or other downloadable virtual instrument format), and for that you'll probably need to go beyond the Arduino.*

I believe the best sounding virtual instruments are recorded samples of real instruments.   I assume the sounds in the VS1053b are synthesized (and probably with rather limited processing power compared to a high-end keyboard like the famous Yamaha DX-7).



* The Arduino is fine for decoding the MIDI signal, but the actual sound generation may require something more powerful with more memory.
43  Using Arduino / Project Guidance / Re: Beep sound problem with MSGEQ7 on: July 04, 2014, 12:49:52 pm
Sorry if this is a dumb question, but do you have a resistor in series with the LED, or is the LED connected directly to the Arduino?
44  Using Arduino / General Electronics / Re: Which power supply needed for a 20W halogen bulb? on: July 03, 2014, 10:23:26 pm
Quote
Would I be ok using a 12v source at 1 Amp or less?
No.   The current is determined by the voltage resistance of the lamp, not the power supply  (Ohm's Law).   You will overload the power supply.   

Ohm's Law still holds, so there are two possibilities - The voltage may drop if the power supply can't supply the current and the power supply may die.  Or, you may get the full 1.7 Amps and the power supply may die.

On the other hand, if you use a 12V, 10A power supply, you'll get the 1.7Amps and you'll be OK.   And, it's always a good idea to get a slightly over rated power supply with some safety margin.
45  Using Arduino / Project Guidance / Re: Reducing DC voltage for a project on: July 01, 2014, 02:13:11 pm
Quote
but the computer takes 19 vdc
19V is an odd value.   Is that the spec, or did you measure it?

Look for a DC-DC converter or an adjustable switching voltage regulator chip.    (A linear regulator is unlikely to handle the power.)

Quote
at 40 watts
A DC-DC converter is likely to have a wattage rating.   Voltage regulators are generally rated by voltage  and current.   (Power = Voltage x Current, so you'll need a little more than 2 Amps.)
Pages: 1 2 [3] 4 5 ... 86