text:
How does coordinator XBee receive data from router?
I have two XBees S2, one is configured as an API coordinator connected to Arduino and the other as an AT router.
The coordinator sends a frame to the router to switch on a LED. I want to switch off that LED with a button and the router send a message to the coordinator to tell him that it switch off the LED.
How can I do this?
I have one Arduino with the coordinator. I'm asking what I have to put in the script to make the coordinator receive the data.
Here is my code, how the coordinator sends the data to the router:
String inputString;
int led = 13;
void setup() {
pinMode(led, OUTPUT);
Seria.begin(9600);
}
void loop() {
while (Serial.available() ) {
// get the new byte:
delay(3);
char inChar = Serial.read();
// add it to the inputString:
inputString += inChar;
}
if (inputString.length() >0) {
Serial.println(inputString);
if (inputString == "on"){
digitalWrite(led,HIGH);
setRemoteState(5);

}
inputString="";
}
}

void setRemoteState(char value){
Serial.write(0x7E); // start byte
Serial.write((byte)0x0);
Serial.write(0x10);
Serial.write(0x17);
Serial.write((byte)0x0);
// id of recipient or use 0xFFFF for broadcast
Serial.write((byte)00);
Serial.write((byte)00);
Serial.write((byte)00);
Serial.write((byte)00);
Serial.write((byte)00);
Serial.write((byte)00);
Serial.write(0xFF);
Serial.write(0xFF);
// 16 bit of reciepent
Serial.write(0xFF);
Serial.write(0xFE);

Serial.write(0x02);

  Serial.write('D');
  Serial.write('2');

 Serial.write(value);

long sum = 0x17 + 0xFF + 0xFF + 0xFF + 0xFE + 0x02 + 'D' + '2' + value;
Serial.write(0xFF - ( sum & 0xFF) );
Serial.print(sum,HEX);
}

When you have one working as AT mode, it puts out whatever comes in, it is also called transparent mode.
You should first define which mode you want to use them and start coding.
If you choose AT, load the firmware for both and use Arduino to check the commands and execute tasks (supposing it is connected to the router).
If the task was done correctly, you send an okay message, otherwise, send error. This is a simple task in AT mode, just use Serial:
if (led == 1)
   Serial.println("ok");
else
   Serial.println("error");

If you choose API mode, it is a little bit different, where you have to mount the packet for sending data and put a message inside it. There are some libs out there you can achieve this.
On the other side, the coordinator will receive the message and interpret it.
If it is in AT mode, just read the serial. In API, you have to decode the packet and check the payload field where the data is located.

To change the state of digital pin 2,D2 set the "value" to 0x05 to switch it HIGH and set the "value" to 0x04 to switch the pin LOW

This is not a very good answer, it is not clear what you are talking about.  You need to consider what you are trying to explain and then read it back from the perspective of someone who does not have the knowledge you have.  I'd suggest reading some other peoples answers and get tips on how to explain what you mean before you answer anymore questions.  I have no doubt you understand what you are talking about, its just that it doesn't come across very well.


text:
I'm using too much RAM. How can this be measured?
I would like to know how much RAM I am using in my project, as far as I can tell, there's no way to actually work that out (other than going through and calculating it myself). I have got to a stage in a rather large project where I have determined that I am running out of RAM.
I have determined this because I can add a section and then all hell breaks loose somewhere else in my code for no apparent reason. If I #ifndef something else out, it works again. There is nothing programatically wrong with the new code.
I suspected for a while that I was getting to the end of available RAM. I don't think I'm using too much stack (although it's possible), what is the best way to determine how much RAM I am actually using?
Going through and trying to work it out, I have problems when I get to enums and structs; how much memory do they cost?
first edit: ALSO, I have edited my sketch so much since starting, these are not the actual results I initially got, but they are what I am getting now.
  text     data     bss     dec     hex filename
 17554      844     449   18847    499f HA15_20140317w.cpp.elf
 16316      694     409   17419    440b HA15_20140317w.cpp.elf
 17346      790     426   18562    4882 HA15_20140317w.cpp.elf

The first line (with text 17554) was not working, after much editing, the second line (with text 16316) is working as it should.
edit: the third line has everything working, serial reading, my new functions, etc. I essentially removed some global variables and duplicate code. I mention this because (as suspected) it's not about this code per sae, it has to be about the RAM usage. Which brings me back to the original question, "how to best measure it" I'm still checking out some answers, thanks.
How do I actually interpret the above information?
So far my understanding is:
`TEXT` is program instruction memory
`DATA` is variables (unitialised?) in program memory
`BSS`  is variables occupying RAM

since BSS is considerably less than 1024 bytes, why does the second work, but the first doesn't? If it's DATA+BSS then both occupy more than 1024.
re-edit: I edited the question to include the code, but now I've removed it because it really had nothing to do with the problem (other than maybe poor coding practices, variable declarations and the like). You can review the code by looking back through the edits if you really want to see it. I wanted to get back to the question at hand, which was more based around: How to measure RAM usage.

I thought I would add, I have added various new sections of code over the last few weeks, then optomised it until it works, but now I have only added half a doz byte vars and I'm done... :(

Do you use String type in your programs? This is known to perform frequent dynamic memory allocations and releases, which may fragment the heap to the point where you may no memroy left.

@jfpoilpret I stay away from Strings because of the overhead. I'm happy working with char arrays, that said, I almost always define all my char arrays with a fixed size (at the moment, I have ONE byte array that isn't purely because I change the content length for different recompiles.

Posting your code here (or to pastebin if it's too big) may hekp find out what problems you encounter with memory.

@jfpoilpret I can't really post the code, it's huge and unfortunately very bloated, spread over 16 files. It was a project that I was allowing to grow well beyond what was required (it is several projects merged together). I'm starting now to break it apart which I'm sure will help to fix the problem. Although there are some parts of it I need people to look at (or guide me on), I'll post those later.

maybe you could just post the section you've removed with #ifndef, that could guve us hints; another point: you've not mentioned what Arduino you use. A list of the libraries you use could be helpful as well. Finally, the output given by avrdude generally (works on Windows) includes the size of static data, that could help a lot.

While your question seems related to runtime memory consumption, you'd like to consider using 1.5.x series of the Arduino IDE: it reports the amount of "static" RAM used by the sketch (variable declarations), right after compilation. It won't be precise if your code uses malloc, but it's a start.

Yeah, ok, I'll edit shortly to include some code. I have made so many chops and changes since last night, removing and tweaking things and looking at avr-size and avr-objdump outputs. I'll put up the code that broke the camels back

I just thought I would add, I don't think there is anything intrinsically wrong with the code above, in fact, if I remove other segments of code, the above works as expected. In fact, that code itself ALWAYS works as expected. It BREAKS elsewhere in code (essentially it breaks serial communication being received).

Regarding your point about bss and data: data is initialized global data that initially resides in Flash and gets copied to SRAM at program start; bss is uninitialized global data that exists only in SRAM. Hence both are using SRAM altogether. What's left in SRAM is for the stack and the heap.

So does that mean used SRAM once underway, would equate to at least .bss PLUS .data? or is there some overlap?

That's a PLUS, there's no overlap (fortunately, would I add!)

You can use the functions provided AVRGCC: Monitoring Stack Usage
The function was intended to check the stack usage but what it reports is the actual RAM that has never been used (during execution). It does so by "painting" (filling) the RAM with a known value (0xC5), and then checking the RAM area counting how many bytes have still the same initial value.
The report will show the RAM that has not been used (minimum free RAM) and therefor you can calculate the max RAM that has been used (Total RAM - reported RAM).
There are two functions:

StackPaint is executed automatically during initialization and "paints" the RAM with the value 0xC5 (can be changed if needed).
StackCount can be called at any point to count the RAM that hasn't been used.

Here is an example of usage. Doesn't do much but is intended to show how to use the functions.
// -----------------------------------------------------------------------------
extern uint8_t _end;
extern uint8_t __stack;

void StackPaint(void) __attribute__ ((naked)) __attribute__ ((section (".init1")));

void StackPaint(void)
{
#if 0
    uint8_t *p = &_end;

    while(p <= &__stack)
    {
        *p = 0xc5;
        p++;
    }
#else
    __asm volatile ("    ldi r30,lo8(_end)\n"
                    "    ldi r31,hi8(_end)\n"
                    "    ldi r24,lo8(0xc5)\n" /* STACK_CANARY = 0xc5 */
                    "    ldi r25,hi8(__stack)\n"
                    "    rjmp .cmp\n"
                    ".loop:\n"
                    "    st Z+,r24\n"
                    ".cmp:\n"
                    "    cpi r30,lo8(__stack)\n"
                    "    cpc r31,r25\n"
                    "    brlo .loop\n"
                    "    breq .loop"::);
#endif
}

uint16_t StackCount(void)
{
    const uint8_t *p = &_end;
    uint16_t       c = 0;

    while(*p == 0xc5 && p <= &__stack)
    {
        p++;
        c++;
    }

    return c;
}

// -----------------------------------------------------------------------------

void setup() {

Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
Serial.println(StackCount(), DEC);  // calls StackCount() to report the unused RAM
delay(1000);
}

interesting piece of code, thanks. I did use it, and it suggests there's 600+ bytes available, but when I bury that in the deeper subs it does reduce, but doesn't wipe out. So MAYBE my problem is elsewhere.

@Madivad Note that this 600+ bytes represents the minimum  available amount of RAM up to the point when you called the StackCount. It doesn't really make a difference how deep you place the call, if the majority of the code and nested calls have been executed before calling StackCount then the outcome will be correct. So for example you can leave your board working for a while (as long as it takes to get enough code coverage or ideally until you get the misbehavior you describe) and then push a button to get the reported RAM. If there is enough then it's not the cause of problem.

Thanks @alexan_e, I have created an area on my display that reports this now, so as I progress over the next few days I'll watch this number with interest, especially when it fails! Thanks again

@Madivad Please note that the given function will not report correct results if malloc() is used in the code

thanks for that, I am aware, it has been mentioned. As far as I'm aware, I'm not using it (I know that there may be a library using it, I haven't checked fully yet).

The main issues you can have with memory usage at runtime are:

no available memory in the heap for dynamic allocations (malloc or new)
no room left on the stack when calling a function

Both are actually the same as the AVR SRAM (2K on Arduino) is used for both (in addition to static data which size never changes during program execution).
Generally, dynamic memory allocation is seldom used on MCUs, only a few libraries typically use it (one of them is String class, which you mentioned you don't use, and that's a good point).
The stack and the heap can be seen in the picture below (courtesy of Adafruit):

Hence, the most expected issue comes from stack overflow (i.e. when the stack grows towards the heap and overflows on it, and then -if the heap was not used at all- overflows on the static data zone of the SRAM. At that time, you have a high risk of either:

data corruption (i.e. the stack ovewrites heap or static data), giving you ununderstandable behavior
stack corruption (i.e. the heap or static data overwrites stack content), generally leading to a crash

In order to know the amount of memory that's left between the top of the heap and the top of the stack (actually, we might call it the bottom if we represent both the heap and the stack on the same image as depicted below), you can use the following function:
int freeRam () {
  extern int __heap_start, *__brkval;
  int v;
  return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
}

In the code above, __brkval points to the top of the heap but is 0 when the heap has not been used, in which case we use &__heap_start which points to __heap_start, the first variable that marks the bottom of the heap; &v points of course to the top of the stack (this is the last variable pushed on the stack), hence the formula above returns the amount of memory available for the stack (or the heap if you use it) to grow.
You can use this function in various locations of your code to try and find out where this size is getting dramatically reduced.
Of course, if ever you see this function return a negative number then it is too late: you have already overflown the stack!

To moderators: sorry for putting this post to community wiki, I must have made somthing wrong while typing, in the middle of the post. Please put it back here as this action was unintentional. Thanks.

thanks for this answer, I literally only JUST found that piece of code barely an hour ago (at the bottom of http://playground.arduino.cc/Code/AvailableMemory#.UycOrueSxfg ). I haven't included it yet (but I will) since I have quite a large area for debugging on my display. I think I've been confused about dynamically assigning stuff. Is malloc and new the only way I can do that? If so, then I have nothing dynamic. Also, I've just learned the UNO has 2K of SRAM. I thought it was 1K. Taking these into consideration, I'm not running out of RAM! I need to look elsewhere.

In addition, there is also calloc. But you may be using 3rd party libs that use dynamic allocation without you knowing (you'd have to check source code of all your dependencies to be sure about it)

Interesting. The only "problem" is that it reports the free RAM at the point where it's called, so unless it's placed in the right part you may not notice a stack overrun. The function I have provided seems to have an advantage in that area since it report the min free RAM up to that point, once a RAM address has been used, it's not reported free any longer (on the down side there may be some occupied RAM bytes that match the "paint" value and are reported as free). Apart from that maybe one way suits better than the other depending on what a user wants.

Good point! I had not noticed this specific point in your answer (and for me that looked like a bug in fact), now I see the point of "painting" the free zone upfront. Maybe you could make this point more explicit in your answer?

I wonder if the Serial.print() functions would still work after your 'freeRam()' function because it might not be too late.  Maybe you could have an ISR call freeRam() and if it is negative write a message out to the Serial monitor. What I don't know is whether you could also report on the sizes of the heap or stack.

It is not advised to use Serial from an ISR. The issue when freeRam() returns a negative value, is that the stack has already overflown over the heap (or the opposite), meaning that some data has been modified unexpectedly. if this is the heap overflowing the stack, it is likely to become an imminent crash. In the opposite, you may not have a crash but some potentially important data would have been destroyed.

When you figure out how to locate the generated .elf file in your temporary directory, you can execute the command below to dump a SRAM usage, where project.elf is to be replaced with the generated .elf file. The advantage of this output is the ability to inspect how your SRAM is used. Do all the variables need to be global, are they really all required?
avr-objdump -S -j .bss project.elf

project.elf:     file format elf32-avr

Disassembly of section .bss:

00800060 <__bss_start>:
        ...

00800070 <measurementReady>:
        ...

00800071 <cycles>:
        ...

00800073 <measurement>:
  800073:       00 00 00 00                                         ....

00800077 <measurementStart>:
  800077:       00 00 00 00                                         ....

0080007b <timerOverflows>:
  80007b:       00 00 00 00

Notice that this doesn't show stack or dynamic memory use as Ignacio Vazquez-Abrams noted in the comments below.
Additionally a avr-objdump -S -j .data project.elf can be checked, but none of my programs output anything with that so I can't tell for sure if it is useful. It supposed to list 'initialized (non-zero) data'.

Or you could just use avr-size. But that won't show you dynamic allocations or stack usage.

@IgnacioVazquez-Abrams about the dynamics, same for my solution. Edited my answer.

Ok, this is the most interesting answer so far. I've experimented with avr-objdump and avr-size and I'll edit my post above shortly. Thanks for this.

I suspected for a while that I was getting to the end of available RAM. I don't think I'm using too much stack (although it's possible), what is the best way to determine how much RAM I am actually using?

It would be best to use a combination of manual estimation and by using the sizeof operator. If all your declarations are static, then this should give you an accurate picture.
If you are using dynamic allocations, then you may run into a problem once you start deallocating the memory. This is due to memory fragmentation on the heap.

Going through and trying to work it out, I have problems when I get to enums and structs; how much memory do they cost?

An enum takes as much space as an int. So, if you have a set of 10 elements in a enum declaration, that would be 10*sizeof(int). Also, every variable that uses an enumeration is simply an int.
For structures, it would be easiest to use sizeof to find out. Structures occupy a (minimum) space equal to sum of its members. If the compiler does structure alignment, then it may be more, however this is unlikely in the case of avr-gcc.

I do statically assign everything as far as I can. I never thought of using sizeof for this purpose. At the moment, I have almost 400 bytes already accounted for (globally). Now I'll go through and calculate the enums (manually) and the structs (of which I have a few—and I'll use sizeof), and report back.

Not sure you really need sizeof to know the size of your static data as this gets printed by avrdude IIRC.

@jfpoilpret That is version dependent, I think. Not all versions and platforms provide that. Mine (Linux, multiple versions) don't show memory use for one, while Mac versions do.

I have searched the verbose output, I thought it should be there, it isn't

@AsheeshR I was not aware of that, mine works fine on Windows.

There is a program called Arduino Builder that provides a neat visualization of the amount of flash, SRAM and EEPROM your program is using.

The Arduino builder makes up part of the CodeBlocks Arduino IDE solution. It can be used as either a standalone program or through the CodeBlocks Arduino IDE.
Unfortunately Arduino Builder is a little old but it should work for most programs and most Arduinos, such as the Uno.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Arduino: load variables with values read from SD card
I am having a bit of trouble loading values stored on an SD card and assigning them to variables within my program. I can achieve this as one big block of data, but would much prefer them to be saved to variables whilst in a loop or some other process.
My txt file has the following 6 ints & floats values, which are displayed vertically in the file:
2
0.003200
312
1
0.720000
8
Each of these values I want assigned to variables data1,....2,3,4,5,6. Unfortunately, the code I use below will never achieve this, but I am clueless as to any theory to solve this problem. Thanks in advance.
myFile = SD.open("test.txt", FILE_READ);
    if (myFile) {
    while (myFile.available()) {
        data = myFile.read();
    }
myFile.close();
}
else {
    Serial.println("Read Error");
}

These are values that change if anyone's thinking why don't I just hard code it instead.

Putting all such variables in a struct could be a good choice, as you can then copy the contents of the struct as raw data to/from the card (though getting at it from another system like a PC would require knowledge of how the Arduino compiler packs structs).  But you can also read the variables one by one; the big problem at present is that your code doesn't have any variables that it even attempts to load from the card.

File implements Stream just like Serial. so you can use parseInt and parseFloat
int n = File.parseInt();
float x = File.parseFloat();
Serial.println(n);
Serial.println(x, 6);

Thanks for the response. I have just had a search for readByteUntil, it sounds like it could be what I'm looking for, but how would this be implemented into my code. How would I distinguish which goes where?

Would I list the parseInts and floats according to the order within my list? And would I put this within the 'available()' method? Thanks.

in your case you do not need readBytesUntil. only parse the numbers like in the code snippet in my answer. parseInt and parseFloat skips the spaces.

myFile = SD.open("test.txt", FILE_READ);
if (myFile) {
while (myFile.available()) {
km = myFile.parseInt();
kmTemp = myFile.parseFloat();
kmrevs = myFile.parseInt();
miles = myFile.parseInt();
milesTemp = myFile.parseFloat();
milesrevs = myFile.parseInt();
        Serial.println(km);
        ........other printlns()
        }
    myFile.close();
    }
else {
    Serial.println("Read Error");
}

Is that what you mean. I could only squeeze in so many characters in this comment.

yes. are there more lines? then while (available()) is ok

The parse functions are only appropriate if you store the values as text.  If they are something like files created by a text editor on a PC that could indeed be appropriate.  OTOH if they are saved from one Arduino session to another, a direct binary copy of how the values would be stored in Arduino RAM may be more fitting.

No there is not more lines, the same data is replaced as and when required.

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Arduino variables loaded from SD card
I am trying to load some variables from an SD card on the start up of my arduino Uno. I have been given some advice but am unable to communicate at the same hours. Using this advice, I have the following edited code, but it doesn't work and I believe that it's my implementation that is the problem. All help would be greatly appreciated.
myFile = SD.open("test.txt", FILE_READ);
    if (myFile) {
        while (myFile.available()) {
            myFile.read();

            km = myFile.parseInt();
            kmTemp = myFile.parseFloat();
            kmrevs = myFile.parseInt();
            miles = myFile.parseInt();
            milesTemp = myFile.parseFloat();
            milesrevs = myFile.parseInt();

            }
        myFile.close();
        }
    else {
        Serial.println("Read Error");
    }

How is it not working? Describe further. And what is actually written in the file you want to read?

The program gathers/calculates 6 pieces of data which is then saved to a text file on an SD card. The text file displays the 6 pieces of data in a vertical list. On power up of the arduino, I am trying to make the program read these 6 bits of data, assigning the values to 6 different variables before the program hits the loop (this script is within setup() if that eliminates a question).

When ran and then restarted the data output is at the programs defaults of '0' & '0.000000' where floats apply....not the data that is saved on the disk.

You still have not listed the file from your SDCard.  Make sure you are using a plain text editor for this.  For example, Microsoft Word or Adobe Framemaker would add an unbelievable amount of overhead that would confuse the parsing library.

what is actually written in the file you want to read? please answer this question.

After the parseInt, the next character will be you delimiter. For example a comma (,). The next time you call parseInt, it will see the comma, and return 0. Try putting a myFile.read(); between each parseInt/parseFloat.

myFile = SD.open("test.txt", FILE_WRITE);
  if (myFile) {
        myFile.println(km);
        myFile.println(kmTemp, 6);
        myFile.println(kmrevs);
        myFile.println(miles);
myFile.println(milesTemp, 6);
        myFile.println(milesrevs);
        myFile.close();
    }
else {
        // SD SAVE ERROR
        Serial.println("Save Error");
    }

That is how I save it. The test.txt file contains the following example numbers : 1, 0.001600, 12, 0, 0.072000, 0. These are listed vertically in the text file using println() in the save method just posted.

Gerben - I tried the myFile.read() which hasn't done anything different

in you previous question, where I answered, you had no commas or new-lines in the example file content. the parseInt and parseFloat ignores only spaces by default.
remove the commas or read them or ignore them with parseInt parameter SKIP_ALL
km = myFile.parseInt(SKIP_ALL);

Hi there is no commas, it's just in the comments section, whenever I press enter it posts the message instead of starts a new line....so I used commas to seperate the different data.

Hi Juraj. I have to admit, I have never analysed anything as much as your two answers. I feel that my bank holiday was no longer wasted as I have finally worked out what you meant. All is rolling amazingly now and it's just what I wanted. Thank you.


text:
Capacitors, Arduinos and Saving Data
In short, I have programmed and wired a speed/odometer and all is working well. However, I need to save data from the components/sensors once a power button is pressed, which has led me down the road of capacitors which seem to be the solution to my problem. Reading online about capacitors has dropped me in the deep end where I would like some help to see if I am thinking right.
I have attached a clearly very crude circuit which I need someone to confirm if I have it correct. If it's important, the whole system ran on 5v, powered by a 9v battery. Is a 5v Capacitor even the right one to use, considering that most components will not be active at the point of powering down?
OLD IMAGE: https://i.sstatic.net/aXhRi.jpg
NEW IMAGE: https://imgur.com/a/aHRpzE4
Just tried to download the app and it's not happening for some reason, so the link(edited) will have to do, I'm sorry.

Err.... no. That is wrong. Very wrong.

This will not work. You have the capacitor in series with the battery, so only an alternating voltage would reach the Arduino. The battery provides a DC voltage, which cannot pass the capacitor. Are you trying to provide power to the Arduino with the capacitor, when the battery is disconnected (so that you have some time to save your precious data)? Then the capacitor has to be in parallel to the Arduino power supply pins. Also you have to sense, if the battery is disconnected, so that the Arduino can sense this and save the data in EEPROM.

Also the capacitance of the capacitor is the important characteristic. You will have to use one with a big capacitance, to provide enough current for the Arduino and your other components.

Hmmm, hold on two secs, just gonna upload another image to confirm we are thinking alike. Thanks btw.

I wouldn’t do it this way. This would make sense if it was mains powered, but not when running of batteries. Use a push button. Then when the Arduino sees that the button is pressed, save the data and turn off the power to the Arduino using a transistor (one example). (On other Arduinos you could even put them to sleep, instead of using a transistor. But on an UNO that won’t work.)

Updated circuit uploaded.

Please don't provide links to images. Upload the images directly (using the image button above the editor).

The onsite image loader doesn't display properly using my mobile, it's just out of site to press the button.

So install the app?

I accept your point about the app, but with all due respect, it's everyone else that is being constructive in relation to the question. The image link is there now, but appologise if causes inconvenience to anyone.

@user4163554 Your "NEW IMAGE" link doesn't work. If a mod tells you to improve the question, you should do so. This isn't just about helping you, it's about the usefulness for future readers, and dead links don't help anyone.

Your "NEW IMAGE" is a link to some site "incur.com" that I have never heard of. My fellow moderator and I would like you to follow posting guidelines and actually post the circuit, not some broken link. Please read How do I ask a good question?.

once a power button is pressed - is it possible to make this power button just be an input to the Arduino, which then writes to the SD card and closes itself down?

Just slapping a random capacitor across your supply is not going to work. It's far more complex than that.
Yes, a capacitor is used to store a charge, but you have to manage that charge properly or you won't get much of a chance to do anything with it.
You need to:

Ensure that the discharge voltage remains high enough to run the chip for long enough to save your data (Note: writing to EEPROM causes an increase in current)
Isolate the capacitor from the rest of the circuit so it only powers the main chip
Monitor the incoming power to know when to do the saving.

A block-diagram of your setup may look something like this:

simulate this circuit – Schematic created using CircuitLab
In that diagram R1 and R2 form a voltage divider so you can monitor the battery voltage. C1 is a big capacitor. We're talking super-cap teritory here. Rated at 9V minimum. The regulator on the Arduino is ignored. You don't want to use it.  Two external regulators are now used to power your project - one direct from the battery to run the breadboard and other external components (which will lose power immediately the battery power is removed) and the other to run the main MCU and nothing else.  The second regulator is isolated from the rest of the circuit by D1, and the capacitor's charge then can only go through that regulator to power the main MCU.
That regulator for the MCU should be a switching regulator (DC-DC, "buck" regulator).  If you use a linear ("LDO") regulator you will waste power and your capacitor will have to be two or three times bigger than otherwise.  Even better would be to have a "buck-boost" regulator that will boost the voltage up to 5V when the input voltage drops below 5V, thus giving you even more life from the capacitor.
An alternative to all this is to use the 47C16 chip (5V) or 47L16 chip (3.3V) to store your data. This is an "EERAM" chip - an EEPROM with RAM buffer and automatic saving to EEPROM at power failure. It works through I2C and needs a capacitor connected to it directly to provide the backup power while it stores the data to EEPROM.

Thanks Majenko. Wow, I take back my comment, lol. It's gonna take a while for me to absorb this but will be right back.

One thing I will say now that you have mentioned EPROM, one of the components is an SD card where the data is being saved...I will just mull over your post though a no.

@user4163554 I have just added a paragraph about using EERAM instead.

@user4163554 SD cards don't play well with capacitor backup. They are far too power hungry and slow.

Thanks Majenko, I appologise for  the delay. I have rewritten my code, got rid of the SD part, now sending it to EPROM instead as mentioned by yourself. All is working good. Thanks again.


text:
What is difference between analog and digital input and output, and when should i use anlog or digital (input or output)?
How should i determine whether to use input as analog or digital and same for output too?

This question is too general. Rather mention the specific problem you want to solve, in which you cannot find a way to decide between analog Vs. digital.

I am making an line follower robot so i am unable to understand  what to use analog or digital pins.

You also need to specify what sensors you are using for your line following robot.

Array of 6 infrared sensor

There must be over 10000 different sensors of this kind. Put exact references please. References will lead you to datasheets, datasheets will lead you to the solution: either they provide an analog signal or a digital one!

Well all i know that this sensor have 12 pins for output, 6 for digital and 6 for analog.

Then I'm afraid you don't know enough to build your robot. You have a lot to learn first.

You will use digital pin modes when dealing with signals that are either "on" or "off", such as an LED, a switch, or another digital IC.
Analog inputs are used when you want to read the voltage potential of something. This is typically used to read analog sensors. Analog outputs are not really analog at all on the Arduino. Instead, the Arduino uses something called PWM to create a pseudo-analog signal.
You can read more about analog and digital here:
https://learn.sparkfun.com/tutorials/analog-vs-digital

Is it same for output too

For digital? Yes. Digital input and output are the same. Analog input is different from analog output. Analog in uses special hardware to determine a the voltage on the pin, while analog output uses PWM to mimic a voltage on the pin, but it is not truly analog out.

Also note that the analog pins can also be used as digital input and digital outputs. In case you run out of pins.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Can't Flash ESP8266 latest firmware, says "Fast Flashing error" and "Invalid head of packet(' ')
I can't figure out how to flash the firmware found on http://www.electrodragon.com/w/ESP8266_AT-Command_firmware. I am using ESP8266 Download tool v3.4.4. When I am adding a firmware in download path it goes on till a fixed percentage (77 or 99..mostly) and gives the error Invalid head of packet, FAST FLASHING ERROR. One more thing is that the tutorials I am using to do this have many download path entries filled in the download tool while mine are just blank. It says upload the combined file to 0x0000. I tried uploading V1.54... file's content (both files) but still got the similar error(https://i.sstatic.net/wiQ5K.png). :P
So anyone could just guide me through this as I am a complete newb into this. Please mention any other information needed in comments.
PS

I am pretty sure the power supply is adequate as I have been using esp8266 with the old firmware smoothly. I have also connected a 200uF capacitor b/w gnd and vcc(3.3v from FTDI).
I have double checked the connections.(Yes, GPIO0 is grounded).
I flashed an earlier version successfully ai-thinker-v1.1.1.bin but when I connected it to arduino IDE serial monitor it started giving unending gibberish text :P.


text:
LCD scrolling down problem
I have a list of set-ups and I only have 2 rows in the lcd , I'm trying to scroll down for the moment and I'm doing this by changing the row in the setcursor function to either 0 or 1.
However since that I'll be having about 10 set-ups I used an equation that will change the rows to 0 and one for the ones I want to display and a negative number for those that I don't want to appear.
The problem is when setting the cursor's row to -1 or 2, it will ignore the one with row one (which is the 2nd row).
Is there a way that I can overcome this problem ? by setting it to a row that will not appear on my LCD?
I'm using #include <LiquidCrystal.h>
and I already set lcd.begin(16, 2);
int  colom[5] = {
    0-goDown,1-goDown,2-goDown,3-goDown,4-goDown  };
for (int i = 0; i < 4; i++) {
    if (colom[i] > 1) colom[i] = -1;
}

  lcd.setCursor(0, colom[0]);
  lcd.print("choise 1 ");
  lcd.setCursor(0, colom[1]);
  lcd.print("choise 2 ");
  lcd.setCursor(0, colom[2]);
  lcd.print("choise 3 ");
  lcd.setCursor(0, colom[3]);
  lcd.print("choise 4 ");
  lcd.setCursor(0, colom[4]);
  lcd.print("choise 5 ");

So here goDown is 0 so choice 1 and 2 should appear, but I'm only getting choice 1 and in the second row it's changing quickly between 2 and 5, it's not constant.
I thought about doing an if condition for each choice but that will be a lot of code to write and it won't be efficient for my application.

What is the LCD library you're using?

#include <LiquidCrystal.h>

This is a bad strategy in general. You should not be issuing print calls for things you don't want to print and relying on the lcd library to filter for you because they're out of bounds.
Call print for only the choices you want to display.
char* menu[] = {
    "choice 1",
    "choice 2",
    "choice 3",
    "choice 4",
    "choice 5",
};
const int numMenuItems = sizeof menu / sizeof *menu;
const int numLcdRows = 2;

// start out at the top of the menu
int scrollPos = 0;

void drawMenu() {
    for (int i=0; i < numLcdRows; ++i) {
        lcd.setCursor(0, i);
        lcd.print(menu[i + scrollPos]);
    }
}

To scroll up or down, just adjust the scroll offset:
inline void scrollUp() {
    if (scrollPos > 0)
        scrollPos--;
}

inline void scrollDown() {
    if (scrollPos < numMenuItems - numLcdRows)
        scrollPos++;
}

Note this is untested code written for a library I've never seen (just inferring how it works from your post); it's for illustration purposes only.

I have written some abstraction code for handling LCD menus, located here: https://github.com/red-green/Arduino_Mobile_OS
Here is the main snippet:
byte menu(String title,const String* strings,byte length) {
  boolean select, esc; static byte item, selection;
  select = false;
  esc = false;
  item = 1;
  lcd.clear();
    lcd.setCursor(0,0);
    lcd.print(title);
    lcd.print(": ");
    lcd.print(item);
    lcd.setCursor(0,1);
    lcd.print(strings[item]);
    delay(100);

  while (!select) {
    uint8_t buttons = lcd.readButtons();
    if (buttons) {
    if (buttons & BUTTON_UP) {
      item--;
    }
    if (buttons & BUTTON_DOWN) {
      item++;
    }
    if (buttons & BUTTON_LEFT) {
      esc = true;
    }
    if (buttons & BUTTON_SELECT) {
      selection = item;
      select = true;
    }

    item = constrain(item,1,length - 1);
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print(title);
    lcd.print(": ");
    lcd.print(item);
    lcd.setCursor(0,1);
    lcd.print(strings[item]);
    if (esc) {
      select = true;
      selection = 0;
    }
    delay(100);

  }
  }
  return(selection);
}

You may need to change the button handling to work with your setup. To call, have an array of items before setup, like this:
const String utilmenuitems[6] = {"back","Random Numbers","Uptime","Device Info"};

You can then call it like:
byte return = menu("Utilities",utilmenuitems,4);


text:
XBee shield communication
I need to communicate between two Arduinos using XBee. I am new to XBee and hardware. The two Arduino Unos need to send a message (number) to each other and light an LED or play a sound, when they come close within a 10 meter distance.
So my doubt is which XBee shield and XBee module I need to purchase. I read about XBee series 2, XB24 etc.

Welcome to [arduino.se]! Could you add more details like what is your application? What do you intend to do? What are your requirements? What have you found? Whats confusing you? We can help only if you give us information which can enable us to do so.

Check out the XBee Buying Guide: https://www.sparkfun.com/pages/xbee_guide

Please add more details to your question, there are a lot of XBee modules and each is good a different purpose. Take a look at the link in my previous comment and learn about the different kinds of modules available and then update your question with specific details.

You lay want to give the following details to your question: the environment in which your 2 Arduinos will need to operate, the maximum distance between them, the quantity of information you need to exchange, the exchange frequency, the exchange direction (in case it might be unilateral)...

thanks guys for your reply. My question has been updated with my requirement. Please check

Your edit made your intention with the XBees a bit clearer, yes. But can you easily detect proximity using only the XBees? I don't know, but that's probably the most important part of your question.

the rssi isn't really a great test on the xbees for the purpose you're after. I hve a few around my place, the furthest is 40m away in a metal shed at the back of my yard. Because xbees are mesh, the rssi for that unit is still pretty good. You might want to look more into BLE

The only way I can think of accomplishing this without some sort of proximity sensor is to measure the signal strength of the XBees.
From page 41 of the datasheet:

DB (Received Signal Strength) Command
AT Command: ATDB
Parameter Range [read-only]:  0x17-0x5C (XBee), 0x24-0x64 (XBee-PRO)
 DB parameter is used to read the received signal
  strength (in dBm) of the last RF packet received. Reported values are
  accurate between -40 dBm and the RF module's receiver sensitivity.
  Absolute values are reported. For example: 0x58 = -88 dBm (decimal).
  If no packets have been received (since last reset, power cycle or
  sleep event), “0” will be reported.

You can use this as a rough estimate of the distance between two sensors. You will have to correlate signal strength to actual distance and obstructions and other factors will cause the reported value to be off.
How to measure XBee signal strength?
This page has an example using Processing (on the computer): XBee Signal Strength

Using a single RF signal that may be on a moving object (which has its own RF absorbing and/or amplifying capability) as a proximity measurement sounds dodgy to me. Ten meters with clear line of sight, ten meters with a steel framed wall between the stations, and ten meters with a wood frame wall with electrical wires running through it will all cause unwanted variance in the measurement.

hi thanks for your reply. I am trying to communicate between these. Can you suggest a tutorial or something for this ? Its ruining my time.

The "XBee" brand has two major types. Series 1 are the original ones, and are often NOT referred to by their series number. Series 2 are the newer mesh network brethren.
Most XBee's and their clones are pin compatible (there is even a Bluetooth replacement 'Bee), thus any XBee shield or adapter can be used for either series.
The difference is largely in their communication protocols. The Series 2 allow more robust mesh networking options. But for a beginner - the original (S1) provide simpler out-of-the-box networking.
There are retail packages available that include a pair of S1 XBees, an Arduino compatible breakout board, and a USB adapter to program them. This allows you to get "on the air" and setup the XBees quickly. For communication between two arduinos, a pair of shields will make physical connectivity much easier.

Adding to Ron's answer, the Series 1 is a lot easier to use, because you have to flash firmware onto Series 2s and do all kinds of setup. The S1s work out of the box.
Another thing to keep in mind is that Xbees use 3.3v I/O pins, while the Arduino uses 5v. Most Xbee shields have a Logic Level Converter to handle this, but there are some that don't, and those could damage your Xbee.


text:
Shield interfere with Serial Communication
I'm new to arduino. I have nexus duino robot as described in http://www.aliexpress.com/item/3WD-48mm-Omni-Wheel-Mobile-Arduino-Robot-Kit-10019/688287804.html, the shield connected with motors and support xbee.
With simple serial comm sketch, I'm able to communicate between arduino and PC if the shield not inserted, but not if I insert the shield as it seem arduino can't receive serial data (still can send data to PC tough). Someone says that the shield might be use RX TX so it interfere with serial comm.
My Questions are, is there a way to check whether the shield use RX TX? If yes, can we make it not interfere with serial comm? Could be other problem causing this serial comm problem?
Thanks in advance.

As always, read the schematics.

Can you give us some more information about the shield, please? There is no information about it on the page you linked to. Model number or datasheet would be good.

You really do need to provide information on the shield, there are many versions out there (and I own half of them ).
In essence, unless you are using an alternate serial port (SerialN) or software serial, then YES, your XBee will be using the same lines as your Arduino. If you are using Serial.print or Serial.write to talk to the XBee, then that is a giveaway too.
The reason for this is the XBee talks to your Arduino through the serial port, but the Arduino IDE also talks to your Arduino (for programming and Serial.print) as well. You can only do one successfully.
In answer to your second question, most likely not. It will be the XBee shield causing you your problems.
edit: I thought I would add, I actually have ONE shield that uses RX and TX but also allows for programming at the same time. This is achieved through a series resistor and (in the case of the shield) an amplifier as well.

I'm back with same problem and with other problem. I'll list my experience:
have to set baud rate to 38400, it's the only value that works when the shield on (no garbage).
for once, I confirm that serial comm is OK even with the shield on, I can instruct the robot to rotate with PC, was very happy and then went sleep. And because it only once it feel like a dream, it wasn't working anymore when I tried to add more instructions.
later I check the motor and realize that one of the wheels won't rotate.
Are these two problems related? Please assist on how to troubleshoot these issues.

All wheels working fine now, just a loose plugged cable, serial comm still not working when the shield attached.
@Madivad, can you give a noob tutorial on how to make the shield that use RX and TX also allow programming at the same time. Thanks in advance.


text:
How to communicate the Arduino board with SIM900?
I have a problem. I bought a SIM900 board, but I can not connect there with the Arduino. To send AT commands on the serial the SIM900 doesn't respond, but the LED indicating that the network is on. I've tried to change the baud rate of 9600 to 19200 in the firmware of the Arduino, but it still fails. I think I'm having a problem with the connections of the SIM900, since this board strikes me as obscure (could not find the schematic on the Internet)
The board I have is identical to this:

I'm 90% sure that I am connecting to the wrong pins. But I tried to reverse the jumpers and even some soldered pins on UART.

Interesting... I have been looking a lot into the various GPRS/GSM/GPS boards available recently, using the SIM 900 or 908. I saw your board on eBay, and was quite interested, but in the end I decided to wait as I could not find any libraries for that particular board. Sorry, that is not much help to you.  I will have another search and see what I can come up with. :-)

If you are interested in a GPRS board, I recommend you buy EFCOM. I worked with her and never had problems. But I need to university research, and takes a long time to get to Brazil, not to mention the price, the dollar is costing R$ 3.22 :( ($1 Dollar =  R$ 3,22 Real) link ebay. There is a saying for this here in Brazil: "The cheap is expensive"

I managed to solve the problem. I connected the ground of SIM900 the Arduino ground. It worked for me :)

Excellent news! You should answer your question by posting the solution, with maybe a photo or diagram of the boards pins that needed connecting, and then marking the question as answered... It will probably help  someone else. :-)

I'll tell you what worked for me, because I didn't find the schematics of this board. But your board may work differently, so it is always good to check the datasheet and the schematic (if you have one).
Power
Be sure to use an external 5V source that can supply up to 2A without dipping significantly.
Code
#include <SoftwareSerial.h>

SoftwareSerial GPRS(7, 8);         //7 = TX, 8 = RX
unsigned char buffer[64]; port
int count=0;
int i = 1;                         //if i = 0, send SMS.
void setup(){
  //delay(10000);
  GPRS.begin(19200);               // the GPRS baud rate
  Serial.begin(19200);             // the Serial port of Arduino baud rate.
  Serial.print("I'm ready");
  Serial.print("Hello?");
}

void loop(){
  if (GPRS.available()){         // if date is comming from softwareserial port ==> data is comming from gprs shield

    while(GPRS.available()){          // reading data into char array
      buffer[count++]=GPRS.read();     // writing data into array
      if(count == 64)break;
    }
  Serial.write(buffer,count);            // if no data transmission ends, write buffer to hardware serial port
  clearBufferArray();              // call clearBufferArray function to clear the storaged data from the array
  count = 0;                       // set counter of while loop to zero
}

if (Serial.available())            // if data is available on hardwareserial port ==> data is comming from PC or notebook
  GPRS.write(Serial.read());       // write it to the GPRS shield
  if(i == 0){
    GPRS.print("AT+CMGF=1\r"); //sending SMS in text mode
    Serial.println("AT+CMGF=1\r");
    delay(1000);
    GPRS.print("AT+CMGS=\"+554988063979\"\r"); // phone number
    Serial.println("AT+CMGS=\"+554988063979\"\r");
    delay(1000);
    GPRS.print("Test\r"); // message
    Serial.println("Test\r");
    delay(1000);
    GPRS.write(0x1A); //send a Ctrl+Z(end of the message)
    delay(1000);
    Serial.println("SMS sent successfully");
    i++;
  }
}

void clearBufferArray(){              // function to clear buffer array
  for (int i=0; i<count;i++){
    buffer[i]=NULL;                  // clear all index of array with command NULL
  }
}

Connection

Testing...
Open the serial monitor Arduino, set the baud rate in 19200 in "Both NL & CR". If not work, set to "Carriage Return". Type "AT" and wait for an OK.

Help
If you need help, these links were useful to me:

http://www.seeedstudio.com/wiki/GPRS_Shield_V1.0
http://www.seeedstudio.com/wiki/GPRS_Shield_V2.0
http://www.elecfreaks.com/wiki/index.php?title=EFCom_GPRS/GSM_Shield

A 1A external supply is questionably insufficient, unless there's a lot of capacitance on the module itself to handle GSM pulseloads.

Is the USB connection from the laptop sufficient?


text:
What is the work of pulseIn?
I have code for an ultrasonic sensor which I found from a site. Here is the code:
#define trigPin 12
#define echoPin 13

void setup() {
  Serial.begin (9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
}

void loop() {
  int duration, distance;
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(1000);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;
  if (distance >= 200 || distance <= 0){
    Serial.println("Out of range");
  }
  else {
    Serial.print(distance);
    Serial.println(" cm");
  }
  delay(500);
}

However, I don't understand the work of pulseIn() function. I mean, I want to know when the time count starts and when it ends. For example, in this code, does the time start at digitalWrite(trigPin, HIGH); or does the time start at the pulseIn() function?
If it's the second one, when it stops, then how does the time give us the distance of an obstacle when I am already delaying 1000 microseconds after I send a ping in air?

The 100us delay for the trigger pin seems a bit long to me. It depends on the brand of your sensor, but a typical value (I use it with HC-SR04) is around 10us.

http://arduino.stackexchange.com/questions/19767/what-if-ultrasonic-sensor-doesnt-detect-object/19772#19772

How can i do this code in assembly languaje - what does that have to do with this question?

From the docs:

Reads a pulse (either HIGH or LOW) on a pin. For example, if value is
  HIGH, pulseIn() waits for the pin to go HIGH, starts timing, then
  waits for the pin to go LOW and stops timing. Returns the length of
  the pulse in microseconds. pulsein

So, in this case, pulseIn(echoPin, HIGH) starts counting the number of microseconds until echoPin goes HIGH and stores that in duration.
It starts and ends on that line, it's what is known as a blocking function. It will really sit there until echoPin goes high and tells you how long it took (unless you specify a timeout).
That also means that any delays you have before or after the pulseIn call don't affect it in any way.
The way you get distance from this time is by the following equation:
distance = (duration/2) / 29.1;

You divide by two because it goes out and back so the time would be double that of a one-way travel. The 29.1 is the speed of sound (which is 343.5 m/s => 1 / 0.03435 = 29.1). So note the result is in CM's, not inches. You could probably figure it out by looking at the data sheet of the sensor or just get a lot of samples relating duration to distance (you would measure the distance manually) and get an equation that is very similar.

I've been Skeeted! Actually, the 29.1 is the speed of sound. Also, just a quick addition: IIRC the reason that there's a pulse to read is the ultrasonic module produces a HIGH signal until the sound makes its way back to the module.

I didn't understand the fourth paragraph. Because if I send a sound pulse in air and wait 2 second it will travel a lot distance. So when I start counting I will be 2 seconds late. So why there isn't any problem if I give delays before pulseIn? @ sachleen. And thanks Annonomus Penguin and sachlee

@shajib0o "pulseIn() waits for the pin to go HIGH, starts timing, then waits for the pin to go LOW and stops timing."

when do the pin go LOW? @sachleen

@shajib0o As far as I can tell, it's that the ultrasonic sensor makes the pin go HIGH when the signal is sent and then LOW when the signal comes back.

Actually, this is wrong. pulseIn(echoPin, HIGH) measures the time until the ECHO pin goes LOW.

@AnonymousPenguin "Actually, the 29.1 is the speed of sound" Well, actually, the speed of sound is 343.5 m/s. Then 1 / 0.03435 = 29.1. Note that the result is measured in cm's, not inches. To calculate the distance you can also do distance = duration / 58.2.

Indeed it would be a problem if you started to measure the pulse length 1000 microseconds after it starts. However, this is not how the HC-SR04 sensor works:

the sensor is triggered by the falling edge of TRIG, at digitalWrite(trigPin, LOW);
the ECHO pulse starts about 0.3 ms after the trigger

That's why a delay of 1 ms doesn't affect the measurement result. pulseIn(echoPin, HIGH) will actually wait for the ECHO pin go HIGH, then start measuring the pulse length until it goes LOW again. As such, the duration of the TRIG pulse can be reduced to 10 microseconds (minimum TRIG duration for HC-SR04), to make the measurements faster.

It is important to know that you do not measure the time from trigger start - by setting the Trigger pin HIGH - up to the Echo signal.
The Sensor HC-SR04 starts the measurement by receiving a HIGH on the Trigger input and then sends, a short time later, the time coded as the length of the HIGH level on the Echo pin.
If you use pulseIn() 2 ms, i.e. 2000μs, after triggering, it should work fine.

I'm not sure how much this adds to, or differs from, the accepted answer.

Don't get confused, as the ultrasonic module has a particular way of working. First you set a pulse in the trigpin. When it ends, the module sends 8 bursts of 40 kHz pulses (and thats actually what is used to measure distance, not your pulse in the trigpin, which goes nowhere). At exactly the moment the first burst is sent, the echo pin sets itself in HIGH. When this is happening, the program is in the line of pulseIn, and since echopin is in HIGH it starts timing (because pulseIN(echopin,HIGH) waits for echopin to be HIGH for start timing). When the first pulse of the 40 kHz bounces in the object and gets back to the receiver, the echopin sets itself in LOW. Then the pulseIn function stops the time and returns it. Then the program continues running. This module is a little bit tricky in order to learn the way of working of pulseIn.


text:
Installing MariaMole (Alternative IDE) on Mac
I've heard about a alternative Arduino IDE called MariaMole and really liked the idea, but I just don't know how to install it on Mac OS X. The GitHub page claims that it is compatible with Mac but I just can't find a tutorial, or instructions, as to how the Git files can be compiled on Mac.

Note: I haven't tried this myself so YMMV; this is just from my general experience and reading; all information comes with citations.
To start, I would recommend opening an issue on GitHub to ask for detailed instructions. I noticed that the website says:

Linux and Mac distributions are still experimental, but MariaMole is working fine on both systems.

so they should have a known recipe for how to do it.

In the mean time, here's how I would proceed. Given that there's a file called CMakeLists.txt in the root directory, you need to:

download and install CMake

Then, install the dependencies listed on the wiki:

Qt 5.2
QScintilla 2
QSerial

After that, I presume just cloning the repo and running cmake in the root directory should do the trick. If you have any further questions, please open an issue on GitHub with your compilation error message for further assistance.

can not find any instruction how to build it.
Just call "cmake" in the root dir does not do anything.
I try to build on Linux.

@wally - you have to run cmake in the root (or top level) directory of where ever you unzipped, or downloaded, the MariaMole source packages.

For mac its not yet released (See website).
To try the experimental mac version, you'll have to compile it yourself with the code found on that github repository you linked to

Actually i'm asking how i compile those source files.


text:
GPS library for Proteus
I am working on a project in which I have to connect my Arduino with a GPS module. In this project I need to get longitude, latitude, time and date from the GPS module and need to send these values via USB to a computer.
On this computer, I am going to design software in Microsoft Visual Studio 2010, which will receive this data and display it on a map.
Now, before designing it in hardware, I want to simulate it on Proteus. I have searched in Proteus but there's no GPS module in it, so does anyone know any GPS module library for Proteus?

As far as I can tell, most GPS modules communicate over serial/UART. In this case, you should be able to add some sort of hardcoded serial string to be sent on the serial pins of the arduino, and as long as it is in the correct format, the GPS library should parse it as if it were from a real GPS module.

I have found the solution to my question so I thought to post it here so that others could also get benefit out of it. Here's the link to GPS Library for Proteus - A complete step by step tutorial on How to download GPS Library for Proteus.
From this link you can download the GPS Library which you need to add to the libraries folder of your Proteus software and you will have the GPS module in Proteus and you can design your simulation quite easily. More details are given in this link.

If you will be using the computer to interface, you don't really need Arduino in the middle.
You can hook the GPS module to the computer using a USB-UART bridge like one below:

The usual GPS modules (ebay or other hobby stores) output NMEA sentences over their serial port. Check the datasheet of your GPS module for the baud rate and the RX/TX pins. Connect the RX and TX lines of your GPS to the USB-serial module and you should be able to see NMEA output on a terminal emulator (set to right baud).
Once you see NMEA sentences over a terminal emulator, you can parse those in your application directly (bypassing terminal emulator) instead of using an Arduino.


text:
Coin Recognition from Parallel Coin acceptor to Arduino
I have one project to do where I have one big problem and I need your help. At this stage, it is not a problem for me to write Arduino program for a money receiver who has an impulse output. But the coin receivers that have a parallel output lines which is described in the manuals in detail how it comes to information in the cables of the coin drop, but I can not hit on a decision on how to program Arduino to know coin type, I hope you any of you have a similar experience and will be able indicating which way to raise in order to get to work this project. Coin model is:

EMP 800 v6
Link to the manual

Any your suggestions may be the my life saver...
Thank you in advance guys...

The biggest problem I see is programming the coin-collector. I think you can make it learn coins with only the dip-switches, but other options seem to only be programmable by PC. The outputs of the coin-collector are simple open collector outputs. So connect the ground to the ground of the Arduino, and the open-collector outputs to the Arduino inputs, and add/enable a pull-up resistor. When a coin is accepted, the input pin will read a short LOW pulse.

Nice Suggestion.   I  will try this for next week and I will inform you what will happen

@Gerben Programming coins on Coin Acceptor is not problem for me I m working in Service Center where my main work is programming Coin and Bill Acceptors and I have all programmers that I need including this EMP's programmer and PC Software too... But problem is output for this channels(1,2,3,4,5,6) I think is different then normal Pulse Output. Pulse gives output by getting Low in 50 - 100 MS one time and that means its 1 impulse but this parallel output I think is difference then IMPULSE ;(

From my reading the datasheet, I gathered that you get a Pulse output on the channel that corresponds to the coin that's being recognized. Fer example, if channel 3 is for a 10cent coin, then you get a LOW pulse on channels 3's output pin.


text:
How do I stop the slave from running the code until master sends a new value? I2C
I'm a total noob when it comes to Arduino. I'm slowly learning stuff. I was trying this code which basically gets input in Arduino1(master) and displays the character in serial monitor of Arduino2(slave). The code words just find but I just need the slave to wait until the master sends the next character. Right now, the slave is continuously printing the character.
Master code:
    #include "Wire.h"
    char ch;

    void setup() {

      Serial.begin(9600);
      Wire.begin();

    }

     void loop() {
      while(Serial.available()==0)
      {}
      ch=Serial.read();
      delay(1000);
      Serial.print("The character that you entered is ");
      Serial.println(ch);

      Wire.beginTransmission(9);
      Wire.write(ch);
      Wire.endTransmission();

        }

Slave code:
#include "Wire.h"
char x;

void setup() {

  Serial.begin(9600);
  Wire.begin(9);
  Wire.onReceive(Event);

}
void Event(char bytes){
  x = Wire.read();
}

void loop() {

  Serial.print("The character that you entered in the other Arduino is ");
  Serial.println(x);
}

I know that this will be simple but I just can't quite figure out what to do. Please help me out

Changed the code. Please check now

send more bytes, read more bytes. collect bytes into a buffer, send the whole buffer and receive a buffer

@Juraj Please translate this into noob language. Sorry. Is there any modification to the code that I can do so I can get the slave to do this?

see master_writer and slave_reader examples in IDE File menu

#include "Wire.h"
volatile char x;
volatile bool received;

void setup() {
  Serial.begin(9600);
  Wire.begin(9);
  Wire.onReceive(Event);
}

void Event(char bytes){
  x = Wire.read();
  received = true;
}

void loop() {

  if (received) {
    received = false;
    Serial.print("The character that you entered in the other Arduino is ");
    Serial.println(x);
  }
}

Make both volatile?

yes, it is called from interrupt of course.


text:
Problem with interrupts
Alright. This is what I wanted to do:
Make a circuit and code the arduino such that there are 2 tactile switches, each with a predefined pwm value.
 Whenever any one button is pressed the led should run at that pwm value, until the button is released. There is
 also an ultrasonic sensor on the same arduino that triggers an interrupt at a threshold distance that
 stops the led. When no button is pressed or the ultrasonic isnt active, the led should run at another pwm value.
Here is the code:(updated)
const int trig = 9;
const int echo = 10;
const int redswitch = 2;
const int yellowswitch = 3;
int redled = 6;
int greenled = 5;
volatile int pwm = 50;

volatile bool rs = LOW;      //RS - RED SWITCH
volatile bool ys = LOW;      //YS - YELLOWSWITCH
bool last_rs = LOW;
bool last_ys =  LOW;
volatile long distance=0;
long duration=0;
long temp=0;

void setup(){
  pinMode(trig,OUTPUT);
  pinMode(echo,INPUT);
  pinMode(redled,OUTPUT);
  pinMode(greenled,OUTPUT);
  pinMode(redswitch,INPUT);
  pinMode(yellowswitch,INPUT);
  Serial.begin(9600);

  attachInterrupt(digitalPinToInterrupt(redswitch), red,CHANGE);
  attachInterrupt(digitalPinToInterrupt(yellowswitch), green,CHANGE);

  digitalWrite(greenled,LOW);
  digitalWrite(redled,LOW);
}

boolean debounce(boolean temp,int switchPin)
{
  boolean current = digitalRead(switchPin);
  if (temp != current)
  {
    delay(5);
    current = digitalRead(switchPin);
  }
  return current;
}

void loop(){

  //Ultrasonic sensor's distance calculation
  digitalWrite(trig,LOW);
  delayMicroseconds(5);

  digitalWrite(trig,HIGH);
  delayMicroseconds(10);
  digitalWrite(trig,LOW);

  duration = pulseIn(echo, HIGH);
  temp = duration * 0.0343 / 2;
  noInterrupts();
  distance = temp;
  rs = debounce(last_rs,redswitch);
  ys = debounce(last_ys,yellowswitch);
  last_rs = rs;
  last_ys = ys;
  if(distance>8)interrupts();

  Serial.println(distance);
  analogWrite(redled,pwm);
  analogWrite(greenled,pwm);
}

void red(){

  if(rs == HIGH) pwm = 150;
  else pwm = 0;

}

void green(){

  if(ys == HIGH) pwm = 250;
  else pwm = 0;

}

Now, when the arduino is connected to my laptop, led runs at the a particular value. But whenever I press a button they go off. Can you help me find out what's wrong here?

remove the constrain(pwm,0,255);. it does nothing. function constrain returns first parameter if the value is in constraints or one if the constraints if the value is outside

you code has too many problems. you use one variable for both outputs. you don't debounce the buttons. you reset PWM in every loop (you don't let it run). and I would say the whole concept of reading the buttons with interrupt is wrong

@Juraj. I use one variable for both outputs because I want both leds to have same pwm value. About deboucing, I forgot that completely. Sorry. And I dont understand this - " you reset pwm in every loop". where do I do that? i am not resetting pwm in loop(). Reading buttons with interrupt - I was following an online tutorial. I'm totally new to arduino. It would be immensely helpful if you could be a bit more clear and precise.

but you set pwm to 0 if one of the buttons is not pushed. PWM runs once started. it should do high, low, high,low,high... but if you start it again and again, it does high, and again high and high. interrupts are good for very short events. people hold the buttons long

I think that interrupts are the the correct way to go. It enables you to do all sorts of slow stuff in your main loop, while you buttons still works. Do not do any read or write in your interrupt functions - you already know the button has been pushed!, and the write happens in your main loop. Do nothing else than change the state of volatile variables. Add debounce.

@hpekristinsen and Juraj. Thanks a lot for that. I will do what you said and will update the code. I will add debounce. And Juraj, people won't hold the buttons long in this case. this is a task given to me and they aren't supposed to do that. And one more thing, should I use HIGH or RISING inside attachInterrupt() I dont quite get the difference

Look at these lines:
distance = temp;
duration = pulseIn(echo,HIGH);
distance = duration * 0.0343 /2;

Here is what they do:

The first line sets the variable distance to zero (that's the value
of temp).
The second line waits for the ultrasonic pulse to reach the target,
bounce against it and come back, while at the same time timing the
whole trip. This can take a long time (several milliseconds). Chances
are your program spends most of its time executing this line.
The third line sets the variable distance to something sensible.

This means distance is zero most of the time (while the second line
executes). When the interrupt fires, there is a very high probability
for the interrupt handler to find a zero distance, and thus to set pwm
to zero.
Simple fix: never set distance to an unreasonable value. Leave it's
value alone until you have a new distance measurement ready, and only
then update that variable. In other words, just remove the first of
those three lines.
But there is a catch now. The variable is four bytes long, and updating
it takes four instructions. There is a small probability that the
interrupt fire in between these instructions. When that happens, the
interrupt handler finds the distance variable half-updated, with a mix
of bytes from the previous and the current distance measurements. This
is called a “race condition”, and is one of the worst kind of bugs you
can meet, because it is very hard to systematically reproduce.
The fix to the race condition is to update the variable with interrupts
disabled. The wrong way to do it is:
duration = pulseIn(echo, HIGH);
noInterrupts();
distance = duration * 0.0343 / 2;
interrupts();

This is bad because interrupts are blocked during the distance
calculation, which is too much. The right way is this:
duration = pulseIn(echo, HIGH);
temp = duration * 0.0343 / 2;
noInterrupts();
distance = temp;
interrupts();

Now interrupts are blocked only while writing the distance variable.
Personally I don't think it is such a great idea to read the buttons
with interrupts. Buttons are extremely slow peripherals. If you make
your code non-blocking, your loop() will always be fast enough to deal
with them. Handling the buttons in loop() means you don't have to
worry about all the bugs that can easily sneak into interrupt-driven
code, like the above mentioned race condition.

Edit: In the original version of your code, interrupts were used to
read the switches. In the edited version, you added a debouncer, and you
don't need interrupts anymore. In fact, the way this version uses
interrupts makes no sense at all. The most problematic bit is the fact
that this code can disable interrupts for arbitrarily long times. This
is not good, and you should be aware that the Arduino's timekeeping
functions rely on interrupts to perform their job.
I suggest you just remove from this code every single line where you see
the word “interrupt” (singular or plural), and you replace
if(distance>8)interrupts();

by
if (distance > 8) {
    red();
    green();
}

or, to streamline things a little bit, by
if (distance > 8) {
    if (ys == HIGH) pwm = 250;
    else if (rs == HIGH) pwm = 150;
    else pwm = 0;
}

I updated the code in the question. Please check it. There is a great improvement. But right now, the problem seems to be that the code does exactly opposite to what i want. The led glows at a particular pwm value when no button is pressed. When it is pressed, it turns off. i want it to happen vice versa. And for this part There is also an ultrasonic sensor on the same arduino that triggers an interrupt at a threshold distance that stops the led -  I use if(distance>8)interrupts(). Is this the right way to go?

@Kishore: see amended answer.

the thing is I'm learning arduino right now. this is like a task that has been given to me. I have to use interrupts in this code. That is compulsory. I myself have another version of the code where i don't use interrupts and it still does the job. But I have to do the same thing with the use of interrupts. So, I can't remove them.

@Kishore: Then forget about my edit, and follow the path given in the first part of my answer. You will have to remove your debounce() function and find a algorithm suitable for interrupt-driven debouncing. An interesting problem in itself.


text:
What is the library m in C++ linker?
Following this guide, it says to include a library in the C++ Linker called m. What is this for?
Specifically, Your second Arduino project.
4) Configure project
5th dot point:

AVR C++ Linker -> Libraries: Under libraries, add arduino_core and m (in that order). Under path, add the path to the correct core library, e.g. "${workspace_loc:/arduino_core/328P_16MHz}"

Bewared of this tutorial that seems quite old and is probably not uptodate now. Note that if you want to use Eclipse, I'd suggest to take a look at this plugin: http://eclipse.baeyens.it/ I use it everyday (currently using 1.2.5.5 as I have not yet installed Arduino IDE 1.5).

@jfpoilpret Is that using the compiler shipped with the Arduino I DE? I actually decided not to use Arduino and go for full fledged C...

Yes it uses the AVR tools that come installed with Arduino IDE. But you can do full-fledged C or C++ with it if you want as it does not perform default #includes like Arduino IDE.

@jfpoilpret Do you have access to strings and vectors?

I haven't checked that but I'd rather stay away from STL and involved dynamic memory allocations for embedded development.

Also I'm not sure if AVR tools support templates as required for STL usage.

@jfpoilpret You can use at least strings in the Arduino IDE, which is one of the many reasons why I'm moving to C instead...

Standard C++ also supports the same kind of string class (maybe the same? I have not checked)

The m library is the "math" library. You have to link with it in most flavours of gnu compilers (it is typically not required in other, as it is included in the standard lib) when using functions and stuff from the header file "math.h".

Is this a library that the compiler knows where is by itself?

Yes, it is enough to indicate "-lm" as an option to the compiler-linker. No necessity to indicate -L(pathToLib).


text:
I want to run jvm on arduino.What minimum configuration do I need?
If Arduino IDE itself is built on Java can I run JVM on the Arduino? If yes how should I do it?

An Arduino is the wrong choice for this task.

Ah, why do you want to do this?

Which limited memory hardware I can use here? I want to use in robotics and want to run machine on java.

Search for "embedded java". Oracle supports it for ARM cores, which is what some of the arduino-like boards such as the Teensy 3.X have, but I doubt they have enough resources to support it.
There is haiku-vm (google it!) that's designed with AVR processors in mind, but I don't know how actively it is being worked on.
Googling "embedded java avr" yields a tremendous amount of results; did you even try that?

Thank you very much for suggestions. I've tried searching vms. They support limited java libraries though. I want to know some other options if any.Also I don't know what hardware resources are required to support jvm.I went through nano vm too.Your suggestions helped me.


text:
Serial Monitor listing rapidly
I am using an infrared sensor and a flex sensor to read values from the serial monitor in arduino, however after maybe ten seconds or so it seems the serial monitor breaks and the printed values start to print out rapidly. Does anyone have any suggestions on why this might occurring. Any information would be highly appreciated.
Thanks.
int previousMillis = 0;

long interval1 = 300;
long interval2 = 350;

void setup() {

    Serial.begin(9600);
}

void loop() {

    unsigned long currentMillis = millis();

    if ( currentMillis - previousMillis >= interval1 ) {
        previousMillis = currentMillis;

        Serial.println( "TIMER IS DONE!" );

        int val1 = analogRead(0);
        Serial.print("Sensor Value 1 is ");
        Serial.println(val1);
        delay(5);
    }
    if ( currentMillis - previousMillis >= interval2 ) {
        previousMillis = currentMillis;

        int val2 = analogRead(1);

        Serial.print("Sensor Value 2 is ");
        Serial.println(val2);
    }
    delay(10);
}

why the two separate intervals?

Two separate intervals are for different sensors, photocell and infrared.

If it's a case you're simply wanting to test sensor 1 precisely every 300ms and sensor 2 at precisely every 350ms, then you'll have to monitor two previousMillis values. I've taken it to mean you wanted to test sensor 2 50ms after sensor 1 as per my code below. Alternatively you could use real timers and interrupts! That's a nice little exploration for you (but unnecessary unless you just want to have a little fun) :)

I'm not completely sure what is going wrong, but you're having two intervals using the same interval variable. So, make a previousMillis1 and previousMillis2, one for each interval.

I hate to start with "I hate delays", but I hate delays :)
Why have you included them? If you want your outputs to be slower, increase your intervals.
Use a state machine instead:
unsigned long previousMillis = 0;
unsigned long currentMillis = 0;

unsigned long interval1 = 300;
unsigned long interval2 = 350;

#define LEDPIN  13

int state = 0;
// 0 = waiting for sensor one interval
// 1 = another 50ms for sensor two

void setup() {
    currentMillis=millis();
    previousMillis=currentMillis;
    Serial.begin(9600);
    pinMode(LEDPIN, OUTPUT);
    digitalWrite(A0, HIGH); // internal pullups
    digitalWrite(A1, HIGH); // internal pullups

}

void loop() {
    currentMillis = millis();
    if ( state == 0 )
    {
        if ( currentMillis - previousMillis >= interval1)
        {
            int val1 = analogRead(0);
            Serial.print( currentMillis );
            Serial.print(" Sensor Value 1 is ");
            Serial.println(val1);
            digitalWrite(LEDPIN, HIGH);
            state = 1;
        }
    }
    else
    {
        if ( currentMillis - previousMillis >= interval2)
        {
            int val2 = analogRead(1);
            Serial.print( currentMillis );
            Serial.print(" Sensor Value 2 is ");
            Serial.println(val2);
            digitalWrite(LEDPIN, LOW);
            state = 0;
            previousMillis = currentMillis;
        }
    }
}

This way, test 2 will only be conducted 50ms after test 1 and then previous millis is reset
edit: I fixed the interval test regarding overflow (which you had correctly in the first place)
edit2: (I'm having too much fun with this)
assuming you want each test conducted at specifically the interval requested (ie sensor 1 every 300ms and sensor 2 every 350ms), I have come up with v2 (and removed the state machine, since it's just not needed)
unsigned long previous1 = 0;
unsigned long previous2 = 0;
unsigned long currentMillis = 0;

unsigned long interval1 = 300;
unsigned long interval2 = 350;

const int LEDPIN = 13;

void setup() {
    currentMillis=millis();
    previous1=currentMillis;
    previous2=currentMillis;
    Serial.begin(9600);
    pinMode(LEDPIN, OUTPUT);
    digitalWrite(A0, HIGH);
    digitalWrite(A1, HIGH);
}

void loop() {

    currentMillis = millis();
    if ( currentMillis - previous1 >= interval1)
    {
        previous1 = currentMillis;

        int val1 = analogRead(0);
        Serial.print(currentMillis);
        Serial.print(" Sensor Value 1 is ");
        Serial.println(val1);
        digitalWrite(LEDPIN, HIGH);
    }
    if ( currentMillis - previous2 >= interval2)
    {
        int val2 = analogRead(1);

        Serial.print(currentMillis);
        Serial.print(" Sensor Value 2 is ");
        Serial.println(val2);
        previous2 = currentMillis;
        digitalWrite(LEDPIN, LOW);
    }
}

edit: including some sample output to indicate a working state:
188609 Sensor Value 1 is 15
188659 Sensor Value 2 is 14
188959 Sensor Value 1 is 14
189009 Sensor Value 2 is 15
189309 Sensor Value 1 is 15
189359 Sensor Value 2 is 14
189659 Sensor Value 1 is 14
189709 Sensor Value 2 is 1017
190009 Sensor Value 1 is 15
190059 Sensor Value 2 is 1002
190359 Sensor Value 1 is 14
190409 Sensor Value 2 is 1013
190709 Sensor Value 1 is 14
190759 Sensor Value 2 is 1019
191059 Sensor Value 1 is 15
191109 Sensor Value 2 is 1004
191409 Sensor Value 1 is 14
191459 Sensor Value 2 is 1019
191759 Sensor Value 1 is 15
191809 Sensor Value 2 is 15
192109 Sensor Value 1 is 14
192159 Sensor Value 2 is 15
192459 Sensor Value 1 is 14
192509 Sensor Value 2 is 14
192809 Sensor Value 1 is 15
192859 Sensor Value 2 is 15
193159 Sensor Value 1 is 14
193209 Sensor Value 2 is 16
193509 Sensor Value 1 is 14
193559 Sensor Value 2 is 15
193859 Sensor Value 1 is 1005
193909 Sensor Value 2 is 1021
194209 Sensor Value 1 is 1021
194259 Sensor Value 2 is 1003
194560 Sensor Value 1 is 1004
194609 Sensor Value 2 is 1020
194909 Sensor Value 1 is 1020
194959 Sensor Value 2 is 1004
195259 Sensor Value 1 is 15
195309 Sensor Value 2 is 1001
195609 Sensor Value 1 is 14
195659 Sensor Value 2 is 1022
195959 Sensor Value 1 is 15
196009 Sensor Value 2 is 998
196310 Sensor Value 1 is 15
196359 Sensor Value 2 is 1019
196659 Sensor Value 1 is 15
196709 Sensor Value 2 is 1002
197009 Sensor Value 1 is 14
197059 Sensor Value 2 is 15
197359 Sensor Value 1 is 14
197409 Sensor Value 2 is 15
197709 Sensor Value 1 is 15
197760 Sensor Value 2 is 13
198060 Sensor Value 1 is 14
198110 Sensor Value 2 is 15
198410 Sensor Value 1 is 15
198460 Sensor Value 2 is 14

this is assuming you want test2 50ms after test1

Thanks for an additional solution, however, I am still getting the issue where only one sensor value displays. Also, the value doesn't get reset over a certain duration, it's static.

Do you mean you're only getting data for sensor 1 and never sensor 2? can you give a sample output of what you are getting? possibly include state and millis values to further diagnose.

You're enabling my procrastination here... I'm setting up a board for a "quick" (LOL) test...

my appologies, I had several bugs in that code. I was hand coding without an ide... try the edited code above, should be better :)

me too, I've had the arduino packed away for far too long... IDE reinstalled, board running... Now I can get back to some of the other projects I've shelved for so long :)

I do have a question and forgive me if it seems obvious, but what is the LED relaying. Is it reacting to the sensors. I seem to be getting a repetitive pattern.

That was for my own testing and just shows when each state activates (it's a more interesting pattern in v2), you can simply remove all that, and the internal pullups if you have them in circuitry (or otherwise not needed)

You are doing math with 2 different types.   One is long and the other is an int.  So, eventually the long will always be lager than the int and the test will always be true.  (A 32 bit long can count up to over 2 billion.  A 16 bit int can only count up to about 32 thousand.)
Also, the method millis() is of type "unsigned long".  So change all your variables to match this type.
Also note that when the millis() timer overflows and start over your program may perform unexpectedly.  Since this rarely happens it may not concern you.

Thank you! This works however, now the monitor won't print both values at the same time. Instead it prints sensor val1 until I stop the program. If I comment out the first if statement with the sensor 1 value and keep the sensor 2 statement the monitor will print val2.

Because it's always the first test that is executed first and previous millis is reset within it

If the types are right, and the test is performed correctly (it is), then the millis() overflow will cause no issue. In fact, in this kind of situation I may use unsigned int rather of unsigned long just to save some memory.


text:
Arduino Piccolo Example Script Error
So I am trying to make an audio visualizer from this tutorial listed here.
So I downloaded all the files needed, and downloaded the code. But when I try to verify it, I get this Error:
C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp: In constructor 'RobotControl::RobotControl()':
C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:8: error: 'LCD_CS' was not declared in this scope
C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:8: error: 'DC_LCD' was not declared in this scope
C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:8: error: 'RST_LCD' was not declared in this scope
C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp: In member function 'void RobotControl::begin()':
C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:18: error: 'MUXA' was not declared in this scope
C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:18: error: 'MUXB' was not declared in this scope
C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:18: error: 'MUXC' was not declared in this scope
C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:18: error: 'MUXD' was not declared in this scope
C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:19: error: 'MUX_IN' was not declared in this scope
C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:22: error: 'BUZZ' was not declared in this scope
C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Robot_Control\ArduinoRobot.cpp:25: error: 'Serial1' was not declared in this scope
core.a(main.cpp.o): In function `main':
C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\hardware\arduino\cores\arduino/main.cpp:11: undefined reference to `setup'
C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\hardware\arduino\cores\arduino/main.cpp:14: undefined reference to `loop'

I've looked this up before, and couldn't find anything on it. So I came here for a last resort.
Any ideas?
EDIT: So I reinstalled the folders, and renamed the LED folder but now I get a new error:
Piccolo:112: error: 'Adafruit_BicolorMatrix' does not name a type
Piccolo.pde: In function 'void setup()':
Piccolo:130: error: 'matrix' was not declared in this scope
Piccolo.pde: In function 'void loop()':
Piccolo:168: error: 'matrix' was not declared in this scope
Piccolo:168: error: 'LED_RED' was not declared in this scope
Piccolo:169: error: 'LED_YELLOW' was not declared in this scope
Piccolo:170: error: 'LED_GREEN' was not declared in this scope
Piccolo:207: error: 'LED_OFF' was not declared in this scope
Piccolo:210: error: 'LED_OFF' was not declared in this scope
EDIT 2: Deleted Robot_Control and got this error:
In file included from Piccolo.pde:34:
C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Adafruit_LEDBackpack/Adafruit_LEDBackpack.h:94: error: expected class-name before '{' token
C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Adafruit_LEDBackpack/Adafruit_LEDBackpack.h:103: error: expected class-name before '{' token
C:\Users\ted\Desktop\Arduino_Sandbox_Windows_01\Arduino\libraries\Adafruit_LEDBackpack/Adafruit_LEDBackpack.h:112: error: expected class-name before '{' token
Piccolo.pde: In function 'void loop()':
Piccolo:168: error: 'class Adafruit_BicolorMatrix' has no member named 'fillRect'
Piccolo:169: error: 'class Adafruit_BicolorMatrix' has no member named 'fillRect'
Piccolo:170: error: 'class Adafruit_BicolorMatrix' has no member named 'fillRect'
Piccolo:207: error: 'class Adafruit_BicolorMatrix' has no member named 'drawLine'
Piccolo:210: error: 'class Adafruit_BicolorMatrix' has no member named 'drawLine'

It sounds like something is incorrectly trying to include the Robot_Control library. Have you made any changes to the code at all?

No I don't believe so...Do you think I should try maybe re-installing the code?

You could maybe try re-installing the IDE (and make sure you've got the latest version). Do the same with any 3rd party libraries too.

As I mentioned in the comments, reinstalling/updating all your 3rd party libraries to the latest versions is probably the first thing to try. Updating the IDE itself may also help.
If that hasn't worked then a forum topic here seems to describe the same kind of issue: http://forum.arduino.cc/index.php?topic=168854.0
One of the users seems to have tracked the problem down to a couple of Adafruit libraries. He suggests the following:

1) Delete the folder "Robot_Control" from Program
  Files\Arduino\libraries\
2) Make sure, that the two Adafruit folders in the same folder are
  named Adafruit_GFX and Adafruit_ST7735. I had them named "AdafruitGFX"
  and "AdafruitST7735", but that was wrong.

Deleting the Robot_Control folder doesn't sound like an ideal solution to me, but perhaps there's an incompatibility which can't be easily fixed. Unfortunately, the Arduino IDE handles libraries in a slightly strange way, so weird problems can happen from time to time.

authors: Ηλεκτρολόγος Μηχανικός


text:
Saving Arduino output to a text file in append mode
I used the code below to save output from an Arduino Uno to a text file.
The problem is whenever I run the code the old data in the text file is deleted.
I don't want the old data to be deleted, what should I change?
import processing.serial.*;
Serial mySerial;
PrintWriter output;
void setup() {
   mySerial = new Serial( this, Serial.list()[0], 9600 );
   output = createWriter( "data.txt" );
}
void draw() {
    if (mySerial.available() > 0 ) {
         String value = mySerial.readString();
         if ( value != null ) {
              output.println( value );
         }
    }
}

void keyPressed() {
    output.flush();  // Writes the remaining data to the file
    output.close();  // Finishes the file
    exit();  // Stops the program
}

See this SO answer for an example.

I think the problem is with your file name it's the same every time as the same-named file with the same extension can not be stored. To solve you can add a variable before your file name that increments every time so your file name gets changed every time and you can store that variable in EEPROM for further use.

There are a couple of ways to append to a text file.

You can either read the entire file in a temporary variable, then append the new data to it and then write to file.

you can implement using printWriter instead like mentioned here:
https://processing.org/discourse/beta/num_1267767630.html

Let me know if it works.


text:
Slice string at “:”
I need to slice a string (eg- 4:288:18464:288:4) at ":" into an array({4, 288, 18464, 288, 4}) I used the following code, but its giving only '4' in the serial monitor when "4:288:18464:288:4," is given to arduino.
void displayString(char* s)
{
  char* text = strtok(s,":");

  while(text != NULL){
  text = strtok(NULL,":");}
}

void loop()
{
  if(Serial.available() > 0)
    {
        str = Serial.readStringUntil(',');
        str.toCharArray(text,99);
    }
  displayString(text);
Serial.println(text);
}

Do you know in advance how many substrings you expect from the original one?

Every string will contain 5 substring. But the number of strings will be different each time.

You don't use strtok the way it should:
char* text = strtok(s,":");
while(text != NULL){
    text = strtok(NULL,":");
}

Your code just replaces, in s, all occurrences of : with 0 (i.e. a byte of value 0, not the ASCII value of '0'), thus terminating each substring.
At the end of displayString(text) call from loop(), text still points to the 1st character of the original string (in your post 4:288:18464:288:4), but that string now terminates at the position of the first :, which explains why Serial.println(text) prints just 4.
Now if you want to split the original string into an array of substrings, as asked in your question, you need to modify displayString this way:
// Maximum number of substrings expected
const int MAX_SUBSTRINGS = 5;
// Array of pointers to each substring after displayString() has been called
static char* substrings[MAX_SUBSTRINGS];

void displayString(char* s) {
    // First clear the array of substrings
    for (int i = 0; i < MAX_SUBSTRINGS; i++)
        substrings[i] = 0;
    // Now split the input string
    char* text = strtok(s,":");
    int i = 0;
    while (text != 0 && i < MAX_SUBSTRINGS) {
        // A toekn was found: append it to the array of substrings
        substrings[i++] = text;
        text = strtok(0,":");
    }
}

After calling displayString(text), you can use its result in loop() as follows:
void loop()
{
    if (Serial.available() > 0)
    {
        str = Serial.readStringUntil(',');
        str.toCharArray(text,99);
    }
    displayString(text);
    for (int i = 0; i < MAX_SUBSTRINGS; i++) {
        if (substrings[i] != 0)
            Serial.println(substrings[i]);
    }
}

Note that this will work ONLY if the original string contains no more than 5 substrings delimited by :. If the max number of substrings cannot be known at compile time, then you'll have to use dynamic allocation, which is generally not a very good idea on embedded platforms.