I have 5 types of such functions with different input parameters.

blink(int a,char* b, int c);
fade(int a,int b,int c);
split(int a,int d); 

and so on from serial input what i want is to call this three functions in any combinations that can be later executed in a loop. For example my serial input is this ..


The Code should also be saved in memory so that when a person reset Arduino. The order of functions execute without waiting for serial input.The order of functions would get change only when person enter serial data to arduino. I have no clue where to begin please help me out.

  • It's obvious that you are a beginner, but you have good ideas and some capacity to think beyond the obvious. You lack training but not imagination. Keep trying. – user31481 Oct 23 '17 at 8:54
  • This sounds very much like a school assignment? – Mikael Patel Oct 23 '17 at 11:19
  • @MikaelPatel. At least is a very good school assignment and I think is a good oportunity to show a good communication strategy. I upvoted it because I feel is a valuable lesson on how to solve things. – user31481 Oct 23 '17 at 11:52
  • @MikaelPatel That's My school assignment Dot matrix demo for which i am making an custom app to add multiple transations with arduino – Ravi Parmar Nov 26 '17 at 6:32

This answer isn't going to give you the code to solve your problem, it is just ideas that you can look at and see what suits you best.

You should be able to find an example on how to read from a serial connection, I'm sure there is at least one example in the IDE.

You need to work out how to encode your data, having it in nice human friendly format (like you have above) is great if you are processing it on a PC but on a processor that is slow and have very limited memory using A,B,C... as the function names might be more practical. It will be smaller to store and quicker to compare.

You want to store the input so it can be read back later. There are a number of ways you can do this but they all need a non-volatile storage medium. You could use an SD card, obviously you'd need an SD reader and the type of reader you get will affect the code you need, but these can be problematic. You can also use EEPROM chips that, you can get little I2C interfaced modules, they have less space than an SD card, but are generally faster (they also have a shorter lifespan, but don't worry I don't you'll ware one out). You can also use the EEPROM that is in the Arduino itself (I've never done this).

It is best to build you program up in small parts, get the reading from serial working, then calling functions, then saving and loading. That way you only have to debug a small bunch of issues at once. If you wanted you could abstract the storage device away from the code by writing a base class that has virtual save and load functions. You could then inherit from this class for the EEPROM or the SD card and changing wouldn't affect the rest of the code.

Like I said at the start I appreciate this answer hasn't given you a step by step guide on how to solve your problem, but hopefully it has given you a few pointers on what you could do and you can research the options from there. Remember when you get stuck on one particular aspect just post a minimal example of what you have tried and explain what you expect it to be doing and people will be more than willing to help.


This answer isn't going to give you the code to solve your problem either, it is just tricks that you can look at and see what suits you best.

[I'm assuming your serial input is all readable text (no binary data).]

Made serial input fixed format: Every function name is 3 letter long, all parameters the same length, and if possible, all function the same number of parameter. That's make parsing things easy, later you can upgrade to variable length parameters.

Know you can write two small functions that read Serial and returns a single element:

String getFunction();
int    getArgument();

Each function will take care of commas and other delimiters. Also, getArgument will convert values as text to binary values.

You loop will look like (pseude-code, don't compile).

void loop() {
  String fn = getFunction();

  if (fn.equals("blink")) {
  if  (fn.equals("fade")) {
 void doBlink() {
    int val1 = readArgument();
    int val2 = readArgument();
    int val3 = readArgument();
    // Do some blink.
 void doFade() {
    // same thing.

Now, if you want to transmit char data (strings, texts), put them at the as last parameter. You will need a third function to read a variable length string until end of the line (or some marker you choose).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.