Show Posts
Pages: 1 ... 127 128 [129] 130 131 ... 361
1921  Community / Bar Sport / Re: I don't like counting braces on: July 31, 2013, 05:09:26 am
Indenting works for me, but I put the opening brace on a new line, I rarely get right across the page  :-

Code:
function foo(x,y)
 {
    bar();
    baz();
    if (x>y)
       {
        xyzzy();
        thud();
       }
  squeak();
 }

of course I auto format before posting any code on the forum, or some people moan :-)

I auto format early and often.

When I write a block I start by putting in both braces then going back up to fill. Or I try to remember when I'm not fixated on an idea that could slip away in a second.

if ( something )
{
}

becomes

if ( something )
{
  whatever
}

Note also the whitespace around parenthesis. It's easier on the eyes which leads to slower burnout and fewer times confusing )) with 1) or )}. My eyes are so bad now I'm using 12 or 14-point font in the IDE (I forget which, it's probably 16 anyway) and 120% on the browser here.

Eyestrain makes head pain and that just slows me down.
1922  Community / Bar Sport / Re: I don't like counting braces on: July 31, 2013, 04:56:55 am
Quote
It's like trying to communicate with someone where the length of the pauses between sentences has some hidden meaning.

-    .-.   ..-  .    smiley

Neat chart for Morse Code:
http://www.learnmorsecode.com/

1923  Community / Bar Sport / Re: I don't like counting braces on: July 31, 2013, 04:49:59 am
Quote
Are there any programming languages, even esoteric ones, that come right out and tell you the level of nesting?
I programmed a lot in occam, and it only uses the level of indentation to define blocks - no braces to count.


 smiley-eek You got to play with Transputers?

MAJOR Envy!

1924  Community / Bar Sport / Re: How to control a cat with an Arduino on: July 31, 2013, 04:47:58 am
He had to use bacon? I just had to act like it was food. Crinkle some plastic first if the dog is the suspicious type. Wrappers mean candy.

1925  Using Arduino / Programming Questions / Re: Problem communicating one-way between XBee’s and then the PC on: July 31, 2013, 04:20:13 am
This won't work unless you want UNO2 to broadcast:

(UNO1 pins 0 & 1) to xbee1 <---> xbee2 to (pins 0 & 1 UNO2 pins 0 & 1) to USB cable <---> PC

because UNO2 to PC will also send xbee2 to xbee1.

This will work if you want discreet communications:

(UNO1 pins 2 & 3) to xbee1 <---> xbee2 to (pins 2 & 3 UNO2 pins 0 & 1) to USB cable <---> PC

because xbee2 is using a different serial channel than the USB to PC connection.

Wiring the xbees to pins 2 & 3 allows connecting both UNO's to the same or different PC's. That's right, you can run 2 IDE windows to 2 USB channels with 2 serial monitors. I've done it to test UNO Software Serial to UNO Software Serial... best reliable speed I can do is 57600.
1926  Community / Bar Sport / Re: How to control a cat with an Arduino on: July 30, 2013, 11:26:39 pm
Waiting to see a cat in a little kitty wingsuit since there already looks to be a cat (fake or rug?) built into a quadcopter.

This is sick so if you're a cat lover, don't look:
http://www.huffingtonpost.com/2013/03/21/andrew-lancaster-cat-skin-rug-auction_n_2925875.html

Lancaster the taxidermist should also become a vet. That way no matter what happens, you get your pet back.


1927  Community / Bar Sport / Re: "The Physics Problem" on: July 30, 2013, 11:17:54 pm
Mine are inner ears and kinesio sense I was born with and trained.
Unfortunately they are not calibrated, nor are my eyes and ears, etc.
All are Mk I OEM wetware parts though the eyes have manufacture defects.
1928  Community / Bar Sport / Re: How to control a cat with an Arduino on: July 30, 2013, 11:10:10 pm
yet
1929  Using Arduino / Programming Questions / Re: I am making my own library, but I don't know how to make array goes well. on: July 30, 2013, 11:09:11 pm
array issue is just a small portion of this project.

If you could make a Menu object that includes Menu objects then they would include menu objects that would include other Menu objects, etc till memory runs out.

Just to knock some of the rust off, you should make a number of the examples work even if the code seems familiar. if you remember coding then you know that close won't cut it.

In your IDE under File is Examples. Do and learn/relearn at least the following:
File->Examples->02. Digital->BlinkWithoutDelay
File->Examples->05. Control-> go through all of these to tighten yourself back up

Other examples;
Forget plain old Blink, it teaches the bad habit of using delay().
The rest, do what interests you or you have questions about. Some need extra hardware.

Everything that uses C++ String objects, convert to C char array strings.
If you never knew C strings (lower case s) then find a string.h tutorial on the web, if you lock yourself into using String objects then you won't get as much help when they start crashing your sketches. UNO has only 2k RAM, Leo 2.5k. String objects waste and shotgun your heap in RAM.
Here are the standard C libraries docs for AVR GCC that Arduino uses, including string.h:
http://www.nongnu.org/avr-libc/user-manual/modules.html

1930  Using Arduino / Programming Questions / Re: Problem communicating one-way between XBee’s and then the PC on: July 30, 2013, 10:23:59 pm
You nees the XBee to be on seperate pins than the Serial UART.

+1

With an UNO leave Serial (pins 0 and 1) for the USB to PC connect.

Connect XBEE to 2 other pins using the SoftwareSerial library:
http://arduino.cc/en/Reference/SoftwareSerial

Here's the reference libraries page:
http://arduino.cc/en/Reference/Libraries

And the standard libraries page:
http://www.nongnu.org/avr-libc/user-manual/modules.html
1931  Community / Bar Sport / Re: How to control a cat with an Arduino on: July 30, 2013, 04:50:51 pm
Would the average long haired cat have a lower terminal velocity than the average short haired cat?


1932  Community / Bar Sport / Re: Electronic Drop Bear Disabler on: July 30, 2013, 01:22:00 am
Somehow I think that something that would keep one safe from drop bears could be even simpler.

1933  Community / Bar Sport / Electronic Drop Bear Disabler on: July 29, 2013, 07:56:06 pm
I don't know if it's a big problem any more but I'm given to understand that a lot of Australians have lost cousins and drinking acquaintances to the dreaded drop bears, though perhaps fewer than to various spiders, snakes, crocodiles, sharks and road warriors.

So I was thinking that perhaps an electronic device using a high frequency sound or some kind of wave perhaps enhanced by magnets could be carried that would cause the drop bear to not drop and if that at some minor price could be sold to save future cousins and mates from being lost to these vicious predators.
I think that with proper research and testing (a couple weeks in the bush might do?) you could almost guarantee that anyone carrying a functioning drop bear disabler would never be actually harmed by a drop bear. In fact the hard part might be proving that the device does not harm the poor drop bears beyond depriving them of food.

Who knows? I might be worth a grant!
1934  Community / Bar Sport / Re: "The Physics Problem" on: July 29, 2013, 04:19:54 pm
And where would you take the angle measure? Bike and rider tilt WRT each other, helmet tilts and turns. I leaned inside of hard turns and lifted the inside leg to let the peg fold up. Helmet always turning, I needed to keep awareness high.
What's your tire-patch angle on a high crown road as opposed to a low crown road? I once went into a T at 45 mph on a bike with low center stand and slid a ways on the crown with the back wheel off the ground before getting back on two wheels and continuing along my way. I was already letting off the throttle, the back wheel didn't torque me and it's the front wheel that keeps you up. A little instinct with a lot of practice behind it, just hang in there and such minor events won't end your happy day. My accelerometer and gyros are built-in and pre-wired.

1935  Using Arduino / Project Guidance / Re: audio audio app on: July 27, 2013, 11:33:42 pm
Ok, I'm looking into some dsp shields.  Do you think I might need a data logging shield?


I get modules instead of shields and wire them with jumpers. I got LC modules very cheap directly from the company. They take 5V (signal and power) and 3.3V power (might not have to but I jumper it) and work with the SPI and SD or SdFat libraries. You have to email LCTECH and ask how much for however many you want. I bought more than 10, there is a small shipping and PayPal charge. OTOH the same modules can be found on eBay and at DealExtreme for not a whole lot and DealExtreme takes credit cards.

I buy direct 1 or more of many modules from LC at a time so it's not a hassle for me. They do have VS1053 DSP modules for voice record and play but I wanted MP3 player capability which turns out needs a solder mod I don't dare try. I can't say if they work right off the bat for voice recording or about the quality but here's a blog on the mod to play MP3's from a member on this forum:
http://www.bajdi.com/lcsoft-vs1053-mp3-module/

All the hacks below should work on Arduino with the SPI and SD or SdFat libraries.

You can make your own SD module pretty cheaply. One way is to get a full size SD adapter for micro-SD card and solder directly to the contacts. Hardest part is voltage-shifting from 5V to 3.4V (plus or minus .3V is okay) which isn't a big deal. If you run the AVR at 3.3V it's not needed at all. 3.3V will make an Arduino 5V pin go HIGH so no need to shift up from the card to the Arduino.

Lot of good breadboarding tips here, the "ghetto micro-SD socket" is about halfway down.
http://www.protostack.com/blog/2011/09/8-breadboard-hacks/
However; Tip 1, on my small breadboards the power and ground rails go full length.

This site shows one of those with level shifters on a proto-board. Did he even spend $5?
http://nathan.chantrell.net/20111128/diy-micro-sd-shield-for-arduino/
I would 'build' the resistors right into the wiring. That's what heat shrink is for, right?  smiley-twist

This one is neat but involves unnecessary work.
http://www.instructables.com/id/SDMMC-fits-in-floppy-edge-connector/
Instead of opening the connector and taking it off the cable then making a custom cable and clamping the connector back... why bother? The next connector down the cable has holes perfect to jumper or plug a male header strip into. What can I say? I use old floppy cables for wire buses, they have 34 lines and multiple connectors, just watch out for the one with the twist or cut it off. It still needs a few resistors or diodes to go 5V to 3.4V.
Pages: 1 ... 127 128 [129] 130 131 ... 361