Show Posts
Pages: 1 [2] 3 4 ... 301
16  Using Arduino / Programming Questions / Re: Having trouble "inserting" new characters to a String object. on: April 16, 2014, 12:29:12 pm
Considering how many people come here for help with Strings, we have enough drama already.
But lately a few of the old heads have left so you don't get the consensus of experience we used to.
17  Using Arduino / Programming Questions / Re: HELP on PWM programmed on: April 16, 2014, 12:23:42 pm
In fact you can remove the controller chip entirely and have it work. Oh yes you can.
You can put the LDR and a resistor in a circuit with a transistor that directly controls power to however many leds and they won't turn ON and OFF but simply run at some level of brightness inverse to what the LDR picks up.

 
18  Using Arduino / Programming Questions / Re: HELP on PWM programmed on: April 16, 2014, 12:18:39 pm
[Yes. i do want to save  power. actually this design project is based on green tech.
So, what i can think is to control an LEDs in my project. It should be control by the amount of light received by LDR. So, i came with this schematic. So,  if you can help me, how can i achieved my goal.. and i can improvise my circuit.  smiley

Use the LDR or maybe a few pointed around to determine the current light level and compute how bright you want your leds in total to be and drive them all to the same brightness using 1 PWM pin to switch the power transistor that powers all of the leds. The PWM takes care of the ON/OFF, all you will see is leds changing brightness.

2 leds running at 50% brightness is basically the same in power and light as 1 led at full bright. Why screw around with extra wires to turn 1 off and the other on when both can go from 0 to full in 255 steps?

Tell you what. Wire 1 led to a PWM pin through a 220 ohm resistor and vary the PWM. You can even use the LDR or turn-pot on an analog pin for input to get the variance.
The 1 led won't just be ON or OFF all the time except when it's turned all the way up or all the way down. But in between it really will turn ON and OFF faster than you can see and it only uses power when it is ON.

19  Using Arduino / Project Guidance / Re: Inconsistent values with Bluetooth and Serial.Read on: April 16, 2014, 12:01:11 pm
Oh no, print turns the data into a string complete with terminating zero and println adds a newline char ('\n') before the zero.

Write is what you use when you want more control and the ability to send raw bytes.
20  Using Arduino / Programming Questions / Re: HELP on PWM programmed on: April 16, 2014, 09:02:53 am
What is the fixation with "some ON, the rest OFF"?

1) PWM turns ON *and* OFF 490 times a second.
2) 10 leds all at 10% PWM uses the same power as 1 led ON all the time.
3) 10 leds all on 1 PWM actually gets you 10 leds with 256 different light/power levels.
4) 10 leds set up so that you can choose how many light up gets you 10 different light/power levels.
5) 10 leds set up with PWM each gets more levels and maybe with enough leds you can see a difference.   
6) Many leds on 1 PWM and transistor is simple wiring and simple coding.
7) Many leds with individual control uses many more parts, more code, and is suited for fancy displays.
smiley-cool You can use "software PWM" to increase the number of levels past 256 a few times over if you want.

Are you trying to save power? Usually that is to save money. If so then why spend a bunch more on the lamp?

You could run your lamp with an 8 pin ATtiny25 and a few more on the same less than $1 chip.
What is it you really want to do?
21  Using Arduino / Project Guidance / Re: RC Car - following tape using sensors on: April 16, 2014, 08:44:17 am
I had a peek on Amazon and surprise to me, there's a CMOS version as well. Look at the price difference!

http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=don+lancaster%27s+ttl+cookbook&rh=i%3Aaps%2Ck%3Adon+lancaster%27s+ttl+cookbook
22  Using Arduino / Programming Questions / Re: Having trouble "inserting" new characters to a String object. on: April 16, 2014, 08:41:10 am
If the allocation doesn't succeed on an Arduino then expect a reset very soon?
It's not like you have an OS to try exceptions with.

The String should be able to insert chars after copying itself bigger to hold them.

The difference to using a char array is that the array has a fixed size and does not copy itself "for you".
That's what I mean by transparent and clean.

UNO has 2K RAM for heap and stack.
Using Strings on an UNO is like running a Monster Truck in a half acre lot. Sure, you can even turn completely around but wow, what a show eh?
23  Using Arduino / Project Guidance / Re: RC Car - following tape using sensors on: April 16, 2014, 08:24:37 am
Then you probably also have Don Lancaster's TTL Cookbook as well...
24  Using Arduino / Programming Questions / Re: HELP on PWM programmed on: April 16, 2014, 03:10:21 am
thanks for the info.. is it possible for me to control the LEDs by using LDR ? Because this project is about green technology, which im going to design a energy saving light which is used inside office or houses. When the LDR detects high intensity of light, only several leds will on.. and if LDR detect low intensity of light (cloudy or dark) all of the leds will on..is it possible ?

Yeah but with PWM you are turning them all on for some percent of the time and off for the remainder (if any) 490 times a second so the leds go from off to dim to semi-bright to full bright. And it doesn't hurt the leds that I know of. PWM gives you brightness control from 0 to 255 == full OFF to full ON.
All your leds are one light. If you have 100 leds and run them at 10% it should be like 10 leds running full time.
 
You can control a bunch of leds on 1 pin and they will all be the same duty-cycle, the same percent brightness.
It's like if you have a 100 Watt incandescent and you only feed it 50 Watts instead of two 50 Watt bulbs and only turn one on. You'd get the same brightness but only need one switch.
25  Using Arduino / Programming Questions / Re: Having trouble "inserting" new characters to a String object. on: April 16, 2014, 02:57:31 am
I'm loath to say but if you have RAM to waste then maybe stick with Strings but I dunno if you have that.

I never liked Strings. They are not transparent while char arrays and string.h functions are totally transparent to me.
Strings copy themselves and delete the old copy. Oh, is that your heap? Stomp, stomp, stomp. Hope you gots lots!

With a char array I am dealing with an ARRAY.
If I need to insert a string within a string I first check if I have room in the array and if so, I memmove() the end to make space in the middle then strncpy() the inserted section since strncpy() does not put a terminating zero at the end of the copied section. And that's it.
But I can do the same without using ANY string.h functions. I simply copy the end of the array string back to where I want to insert the new section with a for-loop the use another for-loop to set the bytes I want inserted into place. I treat the array as an array and I don't need no stinking functions I don't know about!

All a char array C string is is a sequence of ASCII chars with a terminating zero (NULL) at the end in a char array.
That is the big hard secret of c strings. Nothing else. You allocate buffers up front and they stay put.
If you want to learn something hard that is well worth the lesson, learn about pointers and referencing until you see it's just how the compiler deals with addresses and realize that storage is all about data and addresses.

I do confess to having a head start before I ever got to C. I semi-learned 3 different assemblers and Forth and the simplicity of view never left.
I can give you hand breaking into string.h commands if you want. PM me. There's really a few basics with variations you can tell by the name, like string copy strcpy() vs strncpy(). The memxxx() functions alone are worth the trip.
26  Using Arduino / Project Guidance / Re: RC Car - following tape using sensors on: April 16, 2014, 02:21:17 am
Good chefs do not learn through rote. They learn the properties of what they work with. Watch through some Good Eats episodes and maybe you will pick up a few basics yourself.  smiley-grin



27  Using Arduino / Programming Questions / Re: HELP on PWM programmed on: April 16, 2014, 02:14:04 am
so.. let say for 1 pin of PWM, can it control 5 LEDs or only 1 ?

It can control as many leds as your transistor can power, provided you give them the power.
Literally, hundreds of regular leds.
You might want to get the EE members here to discuss power FETS.

28  Using Arduino / Project Guidance / Re: RC Car - following tape using sensors on: April 16, 2014, 01:11:10 am
I think we need to hear from the OP.
29  Using Arduino / Programming Questions / Re: HELP on PWM programmed on: April 15, 2014, 11:38:46 pm
PWM at 1 out of 255 is just under 0.4% brightness. That's the same a 1 led out of 255 being ON 100% of the time and the rest OFF, except they would ALL be on 0.39% of the time without having to figure out which some of them should be On or OFF, just all the same.

30  Using Arduino / Project Guidance / Re: RC Car - following tape using sensors on: April 15, 2014, 11:26:52 pm
Maybe some small part luck but I think I saw some very thorough work and not just a few chips.
Somehow I doubt all that is just to run a line follower!

I just can't see replacing a dollar or so in parts with a dev board and a bunch of code to do the same job.

Pages: 1 [2] 3 4 ... 301