Loading...
  Show Posts
Pages: 1 ... 53 54 [55] 56 57 ... 68
811  Using Arduino / Installation & Troubleshooting / Re: Setting up the Arduino environment properly on: January 01, 2012, 07:52:53 pm
Each library is a directory in itself containing two or more files. That directory goes inside the Arduino/libraries/ directory. So if you downloaded "coollib1" and "epicwinyeah" you would have:

My Documents/Arduino/libraries/coollib1/coollib1.cpp
My Documents/Arduino/libraries/coollib1/coollib1.h
My Documents/Arduino/libraries/epicwinyeah/epicwinyeah.cpp
My Documents/Arduino/libraries/epicwinyeah/epicwinyeah.h
812  Using Arduino / Programming Questions / Re: Using detachInterrupt() inside ISR on: January 01, 2012, 04:17:33 am
I've done it, it's fine. ISRs are not magical beings; the registers are only looked at when the pin changes.
813  Using Arduino / Programming Questions / Re: Writing from Serial to Char array and then Serial.print(array) not working on: January 01, 2012, 12:17:25 am
That makes sense that the compiler needs to know how much memory to allocate to myString but is there any way to do it on the fly?  I won't know before hand how many bytes are going to be sent.  It will be comma delimited data that I will need to break up into separate variables to update my Setpoint, Kp, Ki, and Kd variables.

Ok, I guess that does compile, but I have no idea why. The general way to do it is to make the char array as big as the biggest set of data you'll need and then go from there. The String class does dynamically allocate memory, but that can lead to fragmentation and bad stuff.
814  Using Arduino / Programming Questions / Re: Writing from Serial to Char array and then Serial.print(array) not working on: December 31, 2011, 11:32:00 pm
That doesn't compile and not just because of the lack of setup() and loop() (the compiler can't find the length of myString)

Anyway, your problem is that you're Serial.print()ing the pointer to the start of the array without saying how long it is. The second argument to print when you're trying to do that is the number of characters to print.
815  Using Arduino / Installation & Troubleshooting / Re: Odd behavior with #if as first statement on: December 31, 2011, 05:11:50 am
The arduino IDE places
Code:
#include <Arduino.h>
before the first c++ command it sees. It pays no attention to #ifs. So if you just put
Code:
char dummy;
before you do any #if s you'll do fine
816  Using Arduino / Programming Questions / Re: Using Keyboard to control a Motorshield on: December 31, 2011, 03:56:21 am
I think your default case is off - you should use the library's stop function since it has to do some special things to actually write to the motors.

Try adding a Serial.println(speed); at the end of the loop function. If the power is lower than about 50, the motor won't move and will make that whining sound.
817  Using Arduino / Programming Questions / Re: Stupid question - Line/return representation in string on: December 31, 2011, 03:41:42 am
println("hi") prints a newline ("\r\n") after "hi" to the serial stream
print("hi)" just prints "hi"

That may or may not be your problem.

To answer your question specifically, \r is the ASCII character carriage return (0xD), and \n is the ASCII character line feed (0xA).

http://en.wikipedia.org/wiki/ASCII
818  Using Arduino / Programming Questions / Re: Programming LoL Shield on: December 30, 2011, 06:54:56 pm
I'm running an Arduino Uno with IDE v1.0 and a LOL Shield v1.5 and have had all kinds of errors. After searching around I decided to drop back to IDE v0023.

Did you try what the OP did?
819  Using Arduino / Programming Questions / Re: Define for Arduino version? on: December 30, 2011, 06:22:35 pm
yes, ARDUINO is defined - it's 22 for 0022 (and 0023 I think...) and 100 for 1.0

It's defined by the IDE at compile time (if you do the verbose setting, you'll see g++ ... -DARDUINO=100 ..., which sets that variable)
820  Using Arduino / Programming Questions / Re: Strung along on Strings..... on: December 30, 2011, 06:21:13 pm
This is what I do for debugging quickly

Code:
#ifdef DEBUG

#define DEBUG_VAR(variable) do {Serial.print(#variable " = "); Serial.print(variable); Serial.print("\t");} while (0)
#define DEBUG_LAST() do { Serial.println(); } while (0)

#else // DEBUG
#define DEBUG_VAR(x) (void) 0
#define DEBUG_LAST() (void) 0
#endif //DEBUG

Then when you want to print a variable you just do:
Code:
int x = 27;
int y = 29;
int z = x + y;
DEBUG_VAR(x);
DEBUG_VAR(y);
DEBUG_VAR(z);
DEBUG_LAST();
and it will print
Code:
x = 27     y = 29     z = 56
821  Using Arduino / Programming Questions / Re: Register Definitions for ATmega328P on: December 30, 2011, 04:07:56 am
The datasheet is very good for all the register descriptions. The header files that contain the information do exist; however, they simply say things like
Code:
#define DDRC _SFR_IO8(0x07)
Code:
#define _SFR_IO8(io_addr) _MMIO_BYTE((io_addr) + __SFR_OFFSET)
Code:
#define __SFR_OFFSET 0x20
Code:
#define _MMIO_BYTE(mem_addr) (*(volatile uint8_t *)(mem_addr))

On linux, they're under /usr/avr/include; on windows they're in
[arduinodirectory]/hardware/tools/avr/avr/include
822  Using Arduino / Programming Questions / Re: Better way, perhaps using pointers? on: December 28, 2011, 10:56:38 pm
http://devmaster.net/forums/topic/266-swapping-two-variables-without-using-a-temp-var/

Using pointers won't help you
823  Using Arduino / Programming Questions / Re: Arduino ISP Bootload Not Working on: December 28, 2011, 07:19:21 pm
Did you disable auto-reset on the programming arduino?
824  Using Arduino / Programming Questions / Re: Toggle button for analogWrite on: December 28, 2011, 07:18:46 pm
I'd clean up the tabbing (go in 1 tab for each { and go out 1 tab for each }, with few if none exceptions) and the spacing (don't have more than 1 or 2 black spaces in a row). You could also change some of the global variables like ledState, sensorValue, outputValue, buttonState, and lastButtonState to variables just within loop() (most of them will have to be made static). You also have some undescriptive names, like reading and sensorPin. You should also change lastDebounceTime to an unsigned long, since that's what millis() returns. Some comments would be nice as well.
825  Using Arduino / Programming Questions / Re: Toggle button for analogWrite on: December 28, 2011, 06:51:04 pm
how about:
Code:
if (ledState) {
  analogWrite(ledStripPin, outputValue);
}
else {
  digitalWrite(ledStripPin, LOW);
}
Pages: 1 ... 53 54 [55] 56 57 ... 68