Show Posts
Pages: 1 2 3 [4] 5 6 ... 304
46  Using Arduino / Project Guidance / Re: Inconsistent values with Bluetooth and Serial.Read on: April 17, 2014, 10:27:06 am
That's very different. If the master is not not connected to a PC the RX/TX is open for use, though strictly IMO it's better to leave the USB open to connect to the PC for debugging. I have a hub and have run dual duinos at the same time, even loaded code into both as part of the debug cycle. It takes a bit of keeping track though.

That means you don't have a 3-way at the salve and do have special conditions to echo BT through USB though any kind of back and forth could leave you with unexplained results.

I would go with separate channels just to be able to isolate and troubleshoot. At this point I don't see clearly where the bit corruption is coming from and wouldn't expect it. For me it'd be bug-hammer and tongs time. Somewhere there's a lesson to be pounded out, for sure!
47  Using Arduino / Project Guidance / Re: RC Car - following tape using sensors on: April 17, 2014, 10:14:57 am
Where I lived, you'd have been one of the older brothers who either went to Nam or prison.
We had good schools but in some rough parts it was unpopular to actually use the opportunity.
48  Using Arduino / Project Guidance / Re: RC Car - following tape using sensors on: April 17, 2014, 02:42:42 am
We learned to learn but I graduated HS 40 years ago, spent 6 years in Scouting concurrent with school and 3 years in drafting and design school. Life was easier back in the day, be sure!

Raschemmel, you should try just a little. Only a little fruit in a lot of curried onions (and garlic, etc) takes the heat down and man oh man what that relish does to chicken breast is not to be missed! One peach or nectarine in a big pan or if you got no fresh fruit then 1/2 tsp or less of preserves will do. You can control the heat by the curry you add, too.
Sometimes I mix up a batch and just eat it with a spoon. The sulfur in onions and garlic is good for your liver.
49  Using Arduino / Project Guidance / Re: RC Car - following tape using sensors on: April 16, 2014, 11:35:19 pm
You seemed to have been saying that a good chef goes by learned recipes.

I like to curry onions, garlic, sage and nectarine, peach or mango when I got them, it makes a great relish.
50  Using Arduino / Project Guidance / Re: Inconsistent values with Bluetooth and Serial.Read on: April 16, 2014, 09:59:43 pm
So both Arduinos have a common ground? A wire that goes from ground of one to ground of the other?

And you still have all the serial channels wired to the RX and TX of each with RX of each going to TX of the other plus whatever diodes zoomcat outlined?

Let me know when you want to try using separate, isolated and testable serial channels between Arduinos and PC (those being Serial on each Arduino going to a PC), and one channel between the Arduinos themselves and one channel just for the Bluetooth. Then we can try each piece and isolate errors to fix them rather than poke at a chain of probables and hope for the best.
 
 
51  Using Arduino / Programming Questions / Re: Having trouble "inserting" new characters to a String object. on: April 16, 2014, 03:45:01 pm
I'll be damned!!!!!

Just tried to add each char to a traditional char array and guess what... it works just fine....
Now on to refresh on how to send char arrays back and forth between functions...

When you declare an array, the name is a pointer (read: address) to the base of the array.

char buffer[ 40 ]; // buffer is now a char * (* means pointer) to element buffer[0].
                             // it can be used in any function where a char * arg is needed.

char *cptr; // this is a 'bare' pointer to type char

cptr = buffer; // cptr points to buffer[ 0 ]
cptr = &buffer[ 5 ]; // the & is the address-of operator. cptr now points to buffer[ 5 ]
cptr += 20; // cptr now points to buffer[ 25 ]

strcpy( buffer, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" ); // filling up buffer

cptr = strchr( buffer, 'S' ); // cptr now points to the first letter S in buffer
byte idx = cptr - buffer; // idx = 18 and buffer[ 18 ] == 'S'

idx = *( cptr ); // now idx == 'S' == 65 + 18...... the * says give me the value at the address of the pointer

Pointers is like indexes only free from the names of arrays. This makes them extremely versatile and useful in functions that work on arrays, char arrays or any other kind of array. The function doesn't need to know what array it is working with and it can return a pointer without regard to array indexes.

Here is more reason to learn the use and power of pointers, you can make a pointer to anything including functions. You can even make an array of function pointers that changes dynamically during run time and have the same control structures run different functions or sets of functions using those pointers. But only if you see a need or algorithmic shortcut of course. But you get none of this, can't even think in these terms unless you learn pointers. IMO pointers are behind almost half if not more than half of C.

Multidimension pointers for multidimension arrays are just pointers to arrays of pointers, etc. Take a while to soak that in when you're ready, some practice here and there and it won't be any more confusing than the rest of C.

So, no pressure. Whenever you're ready there's a really good and worthwhile step in your coding education. Working with char array strings will help you understand pointers and pointers will help you with strings.

C++ String Objects OTOH, don't teach you much about these though you can point inside of the mystery box String Object. And then you add 1 char to the String and the box moves and your old pointer is useless... which is how I feel about "please insulate me from the realities of my hardware and my code that I'm too lazy or stupid to learn" C++ String Objects.
52  Using Arduino / Project Guidance / Re: Inconsistent values with Bluetooth and Serial.Read on: April 16, 2014, 03:05:31 pm
Single quotes go around 1 text char and the compiler uses the ASCII value of the text char.

char txt = 'A'; // txt will == 65
txt += 4; // txt == 69, would print as E

or

  num = Serial.read();
  if (( num >= '0' ) && ( num <= '9' )) // then num is a digit and not something else sent by mistake
  {
//  do something number-y
  }

Double quotes go around string constants and always get a zero added at the end.

char *msg = "this is a message"; // allocates 18 bytes RAM and fills it with the text and a terminating NULL byte.

char buffer[ 32 ];
....
  strcpy( buffer, msg ); // now buffer holds the string msg with the unfilled chars unchanged, they started as 0's.
....
  strcpy( buffer, "foo" ); // now buffer holds foo\0 is a message\0\0\0\0 etc where \0 is a char == 0.

These are just ways to tell the compiler what to do with the text in your readable, not always numbers source code.

As for print and write, those are well covered here in Serial:
http://arduino.cc/en/Reference/Serial

The (basics, not everything) Reference is here:
http://arduino.cc/en/Reference/HomePage

The Arduino Libraries:
http://arduino.cc/en/Reference/Libraries

The underlying GCC AVR_LibC (that Arduino runs on) libraries (the AVR standard C libraries):
http://www.nongnu.org/avr-libc/user-manual/modules.html

And the user-contributed code, aka The Playground index:
http://playground.arduino.cc/Main/GeneralCodeLibrary

This is the Examples page. The examples code for your IDE release comes with your IDE and load through the IDE File menu, File->Examples->etc, you'll see, go through 1,2,3 and 5. Section 4 teaches bad habits so avoid it!
http://arduino.cc/en/Tutorial/HomePage

At the top of the Examples page are links to Foundations and Hacking. Both are very good pages to look through.

There's more on the Arduino site and tons more on the web. Search is your friend!
Keep your bookmarks organized and use tabs in your browser, it will make life easier..
53  Using Arduino / Project Guidance / Re: RC Car - following tape using sensors on: April 16, 2014, 02:21:37 pm
The Tinys are neat and small and cheap enough to not care as much that you might brick one. I picked up a dozen 85's to justify shipping on an order from Mouser and so far only used one, but they're here if I ever need another.

What do they need? Power and a bypass cap or two. That's it to run at 8 MHz and have a choice of 3V or 5V operation. Almost no pins, RAM or flash yet the little freaks have plenty of "attention" to give those pins.
I haven't tried it yet but they look like I could just bend the legs out and slide female jumpers on. It's only a shame I don't have a bag of female crimp pins. Or maybe I do... somewhere.
 
And a Tiny might impress the prof more than a full size board.

If you do go with stand-alone chips, OP, and buy from a source with shipping charges then buy some extras and maybe different types for later messing with like a couple of 328P's and possibly a 1284P (but $7 for that one, it's pretty loaded for an AVR) and make double sure that you get Through Hole, DIP package chips as the others, the surface mount chips don't have nice size pins but need special soldering methods and a board to use.

Here's another stand-alone chip link, a very complete blog on 2 minimalist breadboard duino's, a 328P and a 1284P:
http://www.gammon.com.au/forum/?id=11637
54  Using Arduino / Project Guidance / Re: RC Car - following tape using sensors on: April 16, 2014, 12:57:01 pm
Freshmen design. How you try is worth more than what you end up with.
For sure check out the popsicle stick line follower. No code required and it can be improved with or without a microcontroller. In fact with the controller it could get REAL fancy/capable with the input of REAL^2 work.

If you want to blow some minds, migrate the controller code to an ATtiny, it's easier than you may think.
You program a Tiny with your Arduino and when the project is done you still have your Arduino and a complete working project.

OLD video, the link to the newer software is below. Don't judge Matt, that's normal dress and speech out there.
https://www.youtube.com/watch?v=30rPt802n1k&feature=list_related&playnext=1&list=SP23C82C496271F7B9

Here's the newest page-o-details and software link for using Arduino 1.0 and since:
http://highlowtech.org/?p=1695

As for code. If you learn code, learn C basics on the Arduino and leave the C++ stuff for some other time.
Your Arduino IDE comes with built in example programs that are explained on the Arduino site.
Mine the Arduino site for bookmarks. You'll need them. You do know how to organize bookmarks in your browser?
55  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.
56  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.

 
57  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.

58  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.
59  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?
60  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
Pages: 1 2 3 [4] 5 6 ... 304