Show Posts
|
|
Pages: [1]
|
|
2
|
Using Arduino / Programming Questions / Re: Question about using pointer reference &
|
on: February 14, 2013, 04:18:29 pm
|
Thank you for your response, very informative and easy to understand  Seems that I've been doing the right thing, though not knowing it for sure. About the variable names, could I ask what specifically was wrong with them and what would be the proper notation? I know they are not to some conventions and I just slapped them in a hurry to test things, normally I use caps in CONSTANTS and descriptiveVariableNames and name_my_functions so they are easy to distinguish from anothers. Maybe not right, but makes reading easier 
|
|
|
|
|
3
|
Using Arduino / Programming Questions / Question about using pointer reference &
|
on: February 14, 2013, 03:37:55 pm
|
Hello I've coded before with C++ on computers and have learned some things in a course once, though then they didn't teach to the 'whys' so much. This is why I'm not sure of some things and don't know the specifics behind some things. My question is of using the reference (&) in a functions parameter list. The code below gives out an increasing reading so it works, but is this coding bad practice, okay to use, totally not how to do it and why so? I'm especially interested in the why part, like is this style hogging memory if I use it extensively or if it isn't suitable for some things. I read the C programming Wikibook entry at http://en.wikibooks.org/wiki/C_Programming/Pointers_and_arrays and just got more confused. I think this holds a truth: C is known for giving you just enough rope to hang yourself So thank you in advance. My code: void setup() { Serial.begin(9600); }
unsigned long i = 0;
void loop() { increase(i); Serial.println(i); delay(500); }
void increase(unsigned long &this_is_not_i) { this_is_not_i++; return; }
Result in serial monitor 1 2 3 4 5 etc.
|
|
|
|
|
4
|
Development / Other Software Development / Suggestion for SD library
|
on: February 10, 2013, 08:23:07 am
|
|
Hello
I would suggest adding a function call SD.end() to the SD library. This would serve the same purpose as Serial.end() does on Serial connection. Basically a shutdown command for the SD card (and library).
Reason for this would be an ease of use and coding for projects that require swapping SD cards on the fly without powering down the Arduino. At the moment the current SD library doesn't like when the card is initialized, removed, reinserted and reinitialized (with the same or different card).
Thank you in advance.
|
|
|
|
|
6
|
Using Arduino / Storage / Re: Arduino SD library, SD.begin and ejecting the card
|
on: January 23, 2013, 11:30:50 am
|
Have you tried to run an experiment like ejecting a crd many times to see if it all still works?
You could also look at the library to see what begin actually does and decide if you need to call it for each ejection.
Don't have an Arduino to play with (yet), but I do need to code for it, so testing is out at the moment. I'll take a look at the library to see if I can figure it out.
|
|
|
|
|
9
|
Using Arduino / Storage / Re: Storing Data
|
on: January 22, 2013, 05:24:45 pm
|
|
Why do you need to shut it down (or reset) 300 times a day? Why it can't stay on?
One option is to have a count for write times for certain address and once the counter hits the limit, the sketch changes the address it uses to write to the EEPROM.
|
|
|
|
|
10
|
Using Arduino / Storage / Re: Storing volatile data in Flash Memory
|
on: January 21, 2013, 03:48:32 pm
|
|
Only option I can think of is to use an external memory module. May I suggest buying an SD card module (like the one Adafruit sells), hooking it up and then using Serial.read() and saving all the data to the card and after all the data is on the card, then access it through your program. Total cost around 20 USD and you can have gigabytes of storage.
|
|
|
|
|
11
|
Using Arduino / Storage / Arduino SD library, SD.begin and ejecting the card
|
on: January 21, 2013, 03:35:19 pm
|
|
Hi everyone. Tried various searches and found a couple of threads that were close to my situation, but not quite.
The library is the SD library that comes with the Arduino IDE (1.0.1).
I have a system with an Arduino MEGA controlling all sorts of things. The instructions come from a text file on an SD card that the controller reads when I push a button. But, once I have completed one set of instructions, I have to eject the card and go to my computer with it to rewrite new instructions on it. Then I'll return to my Arduino, insert the card and press that button to get it going again. Arduino will not (and can not) reset in between.
But, the library tutorials don't say a word on what I should do in this kind of situation, the usual instructions just assume the card is mounted till power down.
So, when I press the button to activate reading from the card, should I always call SD.begin() to initialize the inserted card?
All I know is that the opened file have to be closed before ejecting, but as there is no SD.eject() to deinitialize the card I had to ask this.
Thank you for you time.
|
|
|
|
|
13
|
Using Arduino / Programming Questions / Explanation of static?
|
on: January 20, 2013, 03:27:34 pm
|
Hello I've recently read a long code and could not find an explanation searching this forum and Google. I would like to know why one would do this: static int function(int *this, int *that) { if (this + that == something) { return 0; } return 1; }
Now, I know what a static variable does inside functions etc., but not one page I could find use the static in defining a function. So, how does that kind of function behave or why would anyone do so? The code that I saw was not commented at all. Thank you very much for your responses!
|
|
|
|
|