Show Posts
Pages: [1] 2 3 ... 70
1  Forum 2005-2010 (read only) / Troubleshooting / Re: String concatenating on: February 14, 2009, 03:28:00 pm
char buffer[10];     // needs to be big enough to hold the longest string plus a terminator
// ...
strcpy(buffer, "00");  // puts digit '0' digit '0' terminator '\0' into buffer
strcat(buffer, "4");   // looks for terminator, copies digit '4' terminator '\0' there

Do some google searching for tutorials using strcat() and strcpy() to start to get an understanding of strings in C.  There are quite a few ways to get strings wrong, which can cause your program to crash or act badly.
2  Forum 2005-2010 (read only) / Troubleshooting / Re: Help needed: direct drive LED matrix on: April 02, 2009, 11:01:01 am
Designrats, if you've tried a bit of tinkering there, but came up with ugly results, then perhaps you might not have noticed a key phrase in my reply:   do this for all LEDs in the correct order.

If you're scrolling columns rightward, you will need to visit all the columns in the opposite order as the given loop, otherwise each copy will damage data you've just written.

Likewise, if you're sliding up or down, then the order you visit the columns isn't important, but the order you copy the rows is key.
3  Forum 2005-2010 (read only) / Troubleshooting / Re: Help needed: direct drive LED matrix on: April 01, 2009, 11:54:30 am
void slidePattern(int pattern, int del) {
  for (int l = 0; l < 8; l++) {
    for (int i = 0; i < 7; i++) {
      for (int j = 0; j < 8; j++) {
        leds[j][i] = leds[j][i+1];
    for (int j = 0; j < 8; j++) {
      leds[j][7] = patterns[pattern][j][0 + l];

This function on that page is responsible for "sliding" the existing contents of the leds[][] array out of view, and replacing them with another pattern.  In particular, leds[j] = leds[j][i+1]; sets a given LED to the value on its right-- do this for all LEDs in the correct order, and you'll see the whole image shift leftward one spot.  Then the statement leds[j][7] = patterns[pattern][j][0 + l]; deals with an LED in the rightmost column, by filling it with the appropriate cell in the next column of the new pattern.

It's a very straight-forward routine.  You could write three other similar routines that slide the contents in other directions.
4  Forum 2005-2010 (read only) / Troubleshooting / Re: Wont power up on: March 31, 2009, 06:04:41 pm
No green power light means the board is fried, or the USB port is disabled.  USB ports will shut down if overloaded, but generally reset like a fuse if you power cycle the computer.
5  Forum 2005-2010 (read only) / Troubleshooting / Re: Slow processing? on: March 31, 2009, 01:57:02 pm
a kind of less attractive default path to take if nothing else is available

That is exactly the way that you should view the concept.
6  Forum 2005-2010 (read only) / Troubleshooting / Re: Slow processing? on: March 31, 2009, 01:39:35 pm
The "internal" resistors are pull-up, not pull-down.  They're equivalent to a 20Kohm resistor attached to +V.  If using internal pullups, then LOW input means pressed, and HIGH input means released.  You can use digitalWrite(ledpin, [glow]![/glow]input) to output the opposite value of input.

If you wire some pull-downs, 10Kohm attached to GND is a good default, as has already been suggested.  If using pulldowns, then LOW input means released, and HIGH input means pressed.

Also, putting your code in [code]...[/code] helps maintain the code indentation and makes it easier to scroll or copy large snippets.
7  Forum 2005-2010 (read only) / Troubleshooting / Re: Error using interrupt function from custom library on: March 30, 2009, 10:35:30 am
Class member functions that appear to take no arguments actually do take an invisible argument called this.  The value of this is the instance of the object you're referring here, erg.  You can't attachInterrupt() to a class member function directly.  You might be able to do it if the member function is static, but my approach is to have a global variable that is the instance, and the global service routine knows how to use the global variable.

MyClass theInstance = NULL;

// Somewhere, fill in an initialized copy of MyClass,
// and set theInstance to it.

    if (theInstance)
8  Forum 2005-2010 (read only) / Troubleshooting / Re: IDE 0013: error compiling (WProgram.h stlib.h) on: February 12, 2009, 07:36:06 am
On that line in avr's stdlib.h is the declaration for int abs(int).

Did you mix up the files with prior versions of the IDE?  Did you call the abs() function with an argument that was cast to integer with this syntax:  int(x) ?  Do any tabs of your sketch end in the .c filename instead of .cpp?
9  Forum 2005-2010 (read only) / Troubleshooting / Re: analogRead conflicting with digitalwrite on: February 28, 2009, 08:54:19 am

Did you also adjust the use of PC6 in setup()?

Are you aware that digital I/O pin 1 is also the USB serial port's transmit pin?  I don't see any Serial.print() but that would definitely hork thinks up.

To explicitly set an analog pin as input, you have to say pinMode(<myanalognumber> + 14, INPUT);  (Since pinMode() expects the numbers 0 to 19, not the analog numbering scheme.)  By default, everything's an input, which is why you often don't see this wrinkle in example sketches.  What you have does no harm to the input, but now your 5th LCD-out pin (digital pin 5) isn't going to work as an output.

So in conclusion, are you sure it's output 1 that's horked, and not output 5?
10  Forum 2005-2010 (read only) / Troubleshooting / Re: EAGLE Question on: February 26, 2009, 11:06:26 am
Plain old screen capture?
11  Forum 2005-2010 (read only) / Troubleshooting / Re: How to add a char to a string? on: February 19, 2009, 08:06:36 am
C++ can fix this, implementing another interface for the strcat() function itself.

void strcat(char* original, char appended)
    while (*original++)
    *original++ = appended;
    if (appended)
        *original = '\0';

After defining this function in your sketch, feel free to strcat(myStringBuffer, 'A') to add the letter A to the end of myStringBuffer.
12  Forum 2005-2010 (read only) / Troubleshooting / Re: Newb Here! Tons of questions on: February 18, 2009, 10:12:35 am
(1) What IS the error you got when you tried to build the "Stepper" library?  How did you attempt to build the library?

(2) myservo.attach([glow]0[/glow]); // attaches the servo on pin [glow]9[/glow] to the servo objects

Attaching things to pin 0 will make it hard to use the serial port, and I think the default library only supports pins 9 and 10.
13  Forum 2005-2010 (read only) / Troubleshooting / Re: Multiple editors... on: February 10, 2009, 07:52:47 am
Each .app can only have one instance running, and the Arduino IDE doesn't give you any support for opening a second window.
14  Forum 2005-2010 (read only) / Troubleshooting / Re: Deriving speed and distance from acceleration on: January 30, 2009, 07:16:55 am

dcb is correct.  Rephrasing the definitions and the code,

Acceleration is the change in velocity over time.  velocity += acceleration * delta_time;

Velocity is the change in position over time.  position += velocity * delta_time;

Mind your units... if you measure delta time in milliseconds, the velocity will be relative to milliseconds.  And as dcb did warn, you will have a LOT of issues with drift, inaccuracy, roundoffs and sensor noise.  You won't be able to dead-reckon your position on a loop race-track and expect the start and end banners to be in the same place every lap.
15  Forum 2005-2010 (read only) / Troubleshooting / Re: Is HIGH = 1 and is pin in pinMode a char? on: February 08, 2009, 03:28:55 pm
Your main tab of a script is automatically granted an invisible #include <WProgram.h> and all your functions in all tabs are automatically and invisibly prototyped so you don't have to fuss with header files quite as much.  The compiler includes headers from your Arduino's ./hardware/cores/arduino folder. Hope that helps your research.
Pages: [1] 2 3 ... 70