how test snips of code in DevC++

Im not trying to emulate the arduino, but some times I want to test some ideas concepts before loan in to the arduino.

For example lets say.... It has occur to me the next idea

instead of use;

int number_fan = 0; 
int fan_sate[6][4] = { 1,1,1,1},
                      {0,1,1,1},
                      {1,0,1,1},
                      {1,1,0,1},
                      {1,1,1,0},
                      {0,0,0,0},
                      
void setup(){
  
}


void loop(){
 if( number_fans  > 5) number_fans = 0; 
    number_fans ++;  
  
  
}

Something like this... I want to test instead;

int number_fan = 0; 
int fan_sate[6][4] = { 1,1,1,1},
                      {0,1,1,1},
                      {1,0,1,1},
                      {1,1,0,1},
                      {1,1,1,0},
                      {0,0,0,0},
                      
void setup(){

  constrain(number_fan, 0,5); 
}


void loop(){
     number_fans ++;  
  
  
}

To see if the roll over variable will work as limit instead of the if comparator...

I try on DevC++

But; Dont recognize int variables, or operators, I guess because the arduino ide load some libraries as default to C++ to work as we know...

Any one know the libraries I must declare in DevC++ to test this and similar codes'?

Thanks.

-Alex.

number_fans or number_fan.

Also to recreate the Arduino program flow, you'll need to add setup and loop calls to int main(). And the Arduino IDE generates prototypes, so you'll need to add your own to the top of your cpp file.

int main();
void setup();
void loop();

int main(){
  setup();
  while(true) loop();
  return 0;
}

void setup(){

}

void loop(){

}

Thanks for the correction I just made it up I dint chek it quite well…

My question merge from the observation that in DevC++
If I declare an int var…the compiler shows… unkow variable type…

There is need to declare a specific library to C++ to recognize the variables?
neither the constrain function appears to be suppourted.

Regards.
Alex.

Try compiling the empty framework I posted. ‘int’ will work fine. Or even try a very basic C++ program:

int main(){
return 0;
}

What errors does this generate?

Constrain isn’t a standard C++ function. You can write your own or simply copy it from the Arduino source:
https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/Arduino.h#L87

Also, byte is Arduino specific, yo’ll have to add that also (or just use unsigned char): https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/Arduino.h#L118

I test thefirs code and compiles it well... Not errors or so...

Thanks for the information... any idea were I cant find more on this?

I will make an empty program to test this things..

"int" is a type in every kind of C

I want to test some ideas concepts before loan in to the arduino.

What advantage does using DevC++ have over loading simple test programs onto the Arduino ?

By the way, neither of your programs would compile and the second one would not do what you want. Also, from the name of the variable it looks like you are wasting space using ints anyway.

Yes int are too much for the example but the DevC++ dont take bytes.

Well in some cases I do have an arduino I just want to see the idea development fast... in other moments I dont have an arduino either is ordered or Im far from lab.

Thanks. -Alex.

AlexLPD: Yes int are too much for the example but the DevC++ dont take bytes.

Read the bottom of reply #3

If you want to guarantee sizes between platforms, use uint8_t, uint16_t, etc...

In DevC++ you'll probably need to include stdint.h to use these.

Thanks a lot pyro_65…

As you send me the github of the arduino… This can be saved an declared as library on the DevC?

#define<arduino.h> or so?

If this is done… will hve the arduino fuctions ?

or for each fuction dont declared as c++ standard will be necessary to copy and paste?

Thanks!