Show Posts
|
|
Pages: [1] 2 3 ... 15
|
|
1
|
Using Arduino / Programming Questions / Re: Why is my code acting like that?
|
on: April 29, 2013, 01:11:37 am
|
I am not familiar with the DHT22 library, but should you be passing the DHT22 by value as a parameter to your read function? This is a guess, but I think the function will be creating its own instantiation of a DHT22 when you do that, which it probably not what you want. Perhaps pass a pointer to your DHT22 object instead: ... DHT22_PrintData( &DHT22_0 ); ... void DHT22_PrintData( DHT22* device) { switch ( device->readData() ) ...
|
|
|
|
|
4
|
Using Arduino / General Electronics / Re: Bouncing exceeding 200 ms
|
on: April 22, 2013, 03:18:52 pm
|
Hardware debouncing might be your friend; see http://www.ganssle.com/debouncing-pt2.htm for some ideas. I have used the RC solution with a model railroad system, where contact between the wheels and rails can be extremely dirty/bouncy. But if you need to detect a button release in less than the bounce time I'm not sure there is a decent solution. At least hardware debouncing has the advantage of automatically "integrating" the amount of time the button is in the closed state.
|
|
|
|
|
7
|
Using Arduino / Programming Questions / Re: New User with Compiler Questions
|
on: January 26, 2013, 02:46:32 pm
|
One can define and instantiate different things depending on which board is targeted, can't you? E.g., hardware serial instantiates more serial objects depending on the target's UARTs: #if defined(UBRRH) || defined(UBRR0H) extern HardwareSerial Serial; #elif defined(USBCON) #include "USBAPI.h" // extern HardwareSerial Serial_; #endif #if defined(UBRR1H) extern HardwareSerial Serial1; #endif #if defined(UBRR2H) extern HardwareSerial Serial2; #endif #if defined(UBRR3H) extern HardwareSerial Serial3; #endif I suppose you could define constants like "PIN47" that would be valid only for a particular board if you were really keen on providing compile-time hardware constraints - not that I think it would be a good idea!
|
|
|
|
|
8
|
Using Arduino / Programming Questions / Re: runtime error... memory overload?
|
on: January 23, 2013, 06:55:57 pm
|
startOfNextPhoto = photosTaken * photoLength; If you anticipate that photosTaken * photoLength will be greater than the value of an int (32,767) then I think you need to tell the compiler to work with long values in the multiplication: startOfNextPhoto = (long)photosTaken * (long)photoLength; Otherwise the result of the multiplication will be an int rather than a long. Of course unless you are using negative numbers you might as well use unsigned ints and unsigned longs.
|
|
|
|
|
9
|
Using Arduino / Programming Questions / Re: Controlling a Kodak Slide Projector via RS232 (P-Com Protocoll)
|
on: January 22, 2013, 04:42:08 pm
|
Are you inverting the serial data from TTL to RS232 in hardware? From the documentation the projector expects RS232-level signals. I think you can try inverting them with Softserial, but that assumes the projector is happy with 0-5v signals rather than true RS232.
As far as i know RS232 is somewhat a NRZ Code, so couldn't be emulated with TTL Levels?! I missed the part in the original post where you specified that you were using a MAX232; never mind!
|
|
|
|
|
11
|
Using Arduino / Programming Questions / Re: Calling function from variable
|
on: January 16, 2013, 10:05:49 pm
|
Are 'mlt' and 'mlf' integer constants? If so, I would use Mikal Hart's Flash library and create a table that holds your values: Something like: FLASH_TABLE(int, servovalues, 6, {mlt, 1600, mlf, 1600, 500, 0}, {values for b}, {values for c}, etc... ); That is, you have a table of 26 rows, each row containing the parameters corresponding to a particular character. Then just look up the appropriate row in the table based on the character received, and pass those values to move2.
|
|
|
|
|
12
|
Using Arduino / Programming Questions / Re: Variable declaring problem
|
on: January 16, 2013, 04:43:30 pm
|
1) You need to declare soil as an array. As your code stands, you would need to declare int soil[7]; so you could reference members 1 to 6. If you number your sensors 0 to 5 instead you could declare it to have only 6 members. 2) You would reference the array as a member of mydata: mydata.soil[sensor] = . . . 3) You declare val2 but never use it; I think you intend to use (val1 + val2) rather than (val1 + val1) ?
|
|
|
|
|
13
|
Using Arduino / Programming Questions / Re: Constructor parameter issues
|
on: January 15, 2013, 04:35:06 pm
|
The constructor is called before the main() function which does all the configuration and initialisation of the Arduino.
Is this always the case? I.e., if you declare a variable in loop() or setup()? Or in a function only called by them?
|
|
|
|
|
14
|
Using Arduino / Programming Questions / Re: Creating objects on the fly?
|
on: January 15, 2013, 02:55:33 pm
|
|
I did something similar for a system where users could arbitrarily add model trains to a layout.
Different manufacturers' trains used different control code, so I implemented a virtual control function in a base class, and had code specific to each system in derived classes. The system would then dynamically create and object of the desired class when it detected the addition of a new train.
|
|
|
|
|