Show Posts
Pages: 1 ... 38 39 [40] 41 42 ... 88
586  Using Arduino / Programming Questions / Re: start code from the begining .How? on: May 06, 2013, 03:46:27 pm
It's still not that clear what you want to do...

loop() will automatically loop/repeat, unless you are stuck in another loop.

You can break out of a for-loop, while-loop, or do-while loop, with break, but you shouldn't generally break-out of your main loop because your program will end and nothing will happen 'till you hardware-reset.

Or as Sembazuru suggested, you may need an [yurl=http://arduino.cc/en/Reference/If]if[/url]-statement.

Quote
I tried with goto but it only works inside their void.

 - loop() is a function.

 - void at beginning of a function prototype or function definition means the the function returns nothing when the function ends/returns.   Otherwise, you'll see the varaible-type that's returned by the function (such as int).

 - The empty parenthesis indicate that no values are passed into the function. 

And FYI - It's generally considered "bad practice" to use goto in C/C++.
587  Using Arduino / Project Guidance / Re: External power Changing my AnalogRead on: May 06, 2013, 03:00:59 pm
I think we need to see a schematic....

The power suppy ground, the Arduino ground, and the sensor ground all should be connected together.   All of the voltages & signals need a common "reference point".    (Of course, the voltage regulator needs to share that common ground too.)    That might not have anything to do with your problem, but it's something to check.  If connecting the grounds causes a problem, something is wired wrong.

Quote
To finding the missing ground or ground disconnection. the moment i connect the ground from my voltage regulator to the arduino that is when i read that 5 volts. at this point i also use a volt meter and checked the voltage out of the sensor and i was getting 25 volts which is what my power supply is putting out.
That's all very confusing...  5 volts where?  Out of the sensor?   Out of the voltage divider?    There are protection diodes on the Arduino inputs and if you have a series current-limiting resistor (or voltage divider), that should clip/limit the analog input voltage to just over 5V (which might not be give you the calculated/expected output from your voltage divider).

Quote
the moment i disconnect that ground the device goes back reading the prox sensor.
So it reads the sensor correctly with the ground disconnected?

588  Using Arduino / Project Guidance / Re: External power Changing my AnalogRead on: May 06, 2013, 12:53:04 pm
You might have a broken ground or missing ground...    Make sure the proximity sensor's ground is connected to the Arduino Ground.   Try turning the computer off with the USB plugged-in (and grounded), but not powered.

589  Using Arduino / General Electronics / Re: Help with schematic (changing GND to 6v) on: May 02, 2013, 06:49:44 pm
Quote
My question is: Can I connect GND to 6v so the voltage difference of the led is 6v??? (12v-6v=6v)
What?   I'm pretty sure the answer is No.  But, I'm not sure I understand.  Where's the 6V coming from?  If you have a 6V supply, why don't you use it directly instead of trying to subtract?

If the 6V & 12V power supplies share a common ground and you ground the 6V supply, you are shorting it out.

You can measure the voltage difference between two power supplies (if they have a common ground), but if you try to pull power (current) from the difference you might have trouble (because you'd be trying to run current "backwards" into  the low-voltage supply.)

 
590  Using Arduino / Audio / Re: How can I control audio volume with Arduino? on: May 02, 2013, 05:05:47 pm
Do you know how a regular/manual potentiometer is wired-up?

Digi-Key lists thousands of different digital pots (I'm sure they are not all in stock).   

10k  to 100k Ohms is a good value for line-level audio.  You'll need two for stereo (or you can get a dual digital pot), but you can connect as many as you want to the same control-signals from the Arduino.  You'll probably want to get a thru-hole package if you want to avoid soldering the smaller surface-mount parts.

Different digital pots are controlled differently, and it's your choice of how you want to do it.   The most common method is serial I2C.  There is an  I2C library for the Arduino, so it shoudn't be too difficult.   Some are controlled with a parallel (binary data) connection.    Some have up/down digital controls, which might have an advantage in that you won't get a sudden full-volume blast if there's a little "glitch" i the control data.

An audio volume control has an "audio taper" (approximately logarithmic).  This is because 50% on a regular (linear) pot sounds a lot closer to full-volume than half-volume (due to our logarithmic hearing).   With a digital pot, this can be handled in your sketch.
591  Using Arduino / Project Guidance / Re: Solar charger shield not charging? on: May 02, 2013, 04:21:59 pm
A quick look at the specs shows a minimum voltage of 2.7V and a typical voltage of 3.7.   It also says 500mA max, but it doesn't say how much light you need, or how much voltage you get at 500mA (maybe 2.7V).   

What are the LEDs showing you?   Have you tried charging without the 70mA load?   Have you measured the voltage & current from the solar cell?   150mA "in the shade" sounds like a lot for a solar cell that puts-out 500mA in direct sunlight...

That 500mA rating might be at noon, in the desert, in the middle of the summer! smiley-grin
592  Using Arduino / General Electronics / Re: Can this damage my led? on: May 02, 2013, 03:59:10 pm
Quote
Ok  So basecly no I'm not damaging my leds, nor my Arduino.
Yes, you are potentially damaging your Arduino!

With 1.3V across each LED, that leaves 2.4V across the 33 Ohm resistor = 73mA out of the Arduino and through all 3 series components.
593  Using Arduino / General Electronics / Re: Can this damage my led? on: May 02, 2013, 03:53:04 pm
Ignoring for the moment that you shouldn't be "pulling" 130mA from the Arduino...

Quote
So now I'm worried that maybe one of the leds might get damaged, because it's linked directly to the 5 volts. Is this true?
That's no problem!    In a series circuit, the voltage gets divided among the components  (and the same current flows through all of them).    If your calculations are correct and the LED is operating narmally, the LED will have 1.3V across it. If you measure the voltage across the LED with a multimeter, you should get 1.3V.  That's the only voltage the LED "sees"...  It doesn't "know anything" about 5V.

If you measure the voltage on the other side of the LED referenced to ground, you should measure 3.7V.  But again, the LED doesn't "know" anything about 5V or 3.7V... It just has 1.3V across it.   

smiley-grin Here's another of my bad analogies - It's like you are standing on a ladder...  You don't really care about how high you are above sea level, you only care about how high the ladder is.
594  Using Arduino / General Electronics / Re: Led light replacement of a 300wat halogen on: May 02, 2013, 03:27:47 pm
Quote
if a heatsync is required then how can such a solution be energy efficient ?
LEDs are not 100% effecient, and high power LEDs need heatsinks.

In the winter, the heat produced by the lightbulb (of any type) reduces the heat required by your furnace, so it's not wasted.   But, electric heat is often more expensive than gas, oil, or coal.   In the summer, if you have air conditioning, you are paying for the wasted heat plus more energy to get rid of that heat!
595  Using Arduino / General Electronics / Re: Led light replacement of a 300wat halogen on: May 02, 2013, 03:20:19 pm
Quote
I know there are various ways to go down from 220v to somethng else, i just dont know what is energy efficient and what is not.
Any "LED power supply" for high-power LEDs will be a switching design that's nearly 100% efficient.  With a switching power supply (under normal operating conditions), you get more current out than you put in (at less voltage).

So you can probably ignore the power loss in teh power supply and just look at the power consumption and light output of the LED(s).  You could subtract 1 or 2 percent for power supply efficiency, but the specs might have that much normal variation anyway.

You can get screw-in LED lamps that have built-in power supplies and run off regular household power (example).   If you just want to turn it on/off automatically, you can do that with a relay (or solid state relay) just like any other AC lamp. Some are dimmable (with a regular AC dimmer), and some are not.

Quote
At home i have a 300 watt halogen lamp, to light-up my room.
I looked-up the light-output for a 300W halogen.   The 1st one I found is about 6000 lumens.     LEDs that put-out that much are very expensive!    I found some floodlight-style 20W LED lamps that put-out 1000 lumens for around $40 USD.  Based on that, I'd guess you are going to need roughly 120W of total LED power.  If those numbers are correct (and you should probably double-check smiley-wink, you'd be reducing you renergy consumption by about 60%.
596  Using Arduino / General Electronics / Re: connecting LEDs to an arduino without a board on: May 02, 2013, 01:39:03 pm
You don't need a board.

You can solder the LEDs directly to  header pins, or solder wires to header pins,  and solder the other end of the wires to the LEDs.

Don't forget current-limiting in series with each LED.  When I solder a resistor inline with an LED, I like to insulate the connection and entire resistor with heat shrink tubing, and I like to use clear heat-shrink just in case I forget the resistor is there in the future.   I like to insulate all "free floating" solder connections with heat-shrink, including where the wire is soldered to the header pin..

But with 10 LEDs, resistors, and ground wires, you are going to have a mess it you try to "affix" the LEDs direclty to the Arduino.    It's better if you can physically mount the LEDs to something else  (a front panel, a perfboard, or ...something).
597  Using Arduino / Project Guidance / Re: Long term operations. Hardware reset needed? on: May 02, 2013, 01:01:38 pm
Quote
I am considering adding a hardware reset circuit comme ci

http://www.playwitharduino.com/?p=291&lang=en

This will operate once a day, which might be a wise precaution against unknown stuffups anyway.
Back in 1994 or 1995, I built a car-alarm for my '94 van.   (Different microprocessor, different timer- scheme).   It's been running 24/7 for almost 20 years!!!  It runs continuously...  Even when it's "off" it's still running and just reading the state of an on/off input and executing a different part of the code.   The only time it's reset is when the battery in the van dies every few years.
598  Using Arduino / LEDs and Multiplexing / Re: pls help me on: May 01, 2013, 07:05:50 pm
Maybe something like:
Code:
int redPin6 = 6;
int redPin7 = 7;
//etc...

int bluePin10 = 10;
int bluePin11 = 11;
// etc.

void setup() {
pinMode(redPin6, OUTPUT);
pinMode(bluePin10, OUTPUT);
//etc.


FYI - When you find yourself doing the same thing over-and-over, it's time to learn about loops. The 3 things that make programming worthwhile are looping, "making desisions" with if-statements, and math.

Besides loop(), there are for-loops, while loops, and do-while loops.  The for loop is the most "popular", because it's easy to initialize variables, increment variables, and stop the loop when it's time to stop.

Nested loops (loops inside loops) are also very common.

For example, in your program you can make a loop that turns the red LED on & off, and run that loop 3 times.  Or, you can put some code in a loop that toggles the LED on or off, depending on it's current state.

If you make the pin number a variable*, you can incriment the pin number so that each time through the loop, a different LED is switched on/off. 


* Actually, it is already an integer variable.   So I can write:
Code:

int redPin = 6;
redPin++;  // redPin is now pin 7
redPin = redPin + 1;  //redPin is now pin 8
redPin = 6;  // redPin is 6 again
I hope you can see how putting something like that in a loop can be very powerful!

 
 
599  Using Arduino / Programming Questions / Re: Help with homework problem decimal to hex conversion on arduino uno on: May 01, 2013, 05:25:21 pm
If I understand your assignment, you only need to add two lines of code?

Code:
//convert character input to number
      //CODE LINE MISSING HERE
      //HINT: Convert input to an integer and store in the number field
I think you just have to convert a number that's in the form of a string, to an integer.  You can look-up the function to do that.

For example, in a string the (ASCII encoded) letter 'A' is represented by 61 (decimal).  The the  character representing the number '1' is not the value one, it's represented by 49 (decimal).

Code:
//display the result
 //CODE LINE MISSING HERE
 //HINT: Call to updateDisplay to show the result
It looks like you just have to call the function.   Do you know how to call a function and pass a couple of values into the function?   

   

600  Using Arduino / General Electronics / Re: Why does an input pin (set for attachInterrupt) have a 5V on it? on: May 01, 2013, 04:30:14 pm
I'm sure someone here knows, but I wonder if the internal pullup is enabled by default????    I was just adding a switch to my current project a few dys ago, and it seemed like it was working OK before I got-around to configuring the pullup.    (I'm not sure...   I didn't play around with it that much because I knew my code wasn't done yet, but it seemed odd.)

Quote
...but I'd like to know why pin 20, which is not set to be an input pin, but should be by default,

The reference does say:
Quote
...Additionally, the INPUT mode explicitly disables the internal pullups.
So if you explicitly set the pinMode to INPUT, that should disable the internal pullup.
Pages: 1 ... 38 39 [40] 41 42 ... 88