Re: Trouble getting a simple sketch working in Arudino IDE
Posted:
Fri Mar 08, 2019 3:14 pm
by schufti
move everything you have now in main() into setup()
Re: Trouble getting a simple sketch working in Arudino IDE
Posted:
Sun Mar 10, 2019 5:31 pm
by SupDoc
I setup the code as follows:
#include <stdio.h>
char buffer[50];
char* s = "geeksforgeeks";
void setup() {
Serial.begin(115200);
// Counting the character and storing
// in buffer using snprintf
int j = snprintf(buffer, 14, "%s\n", s);
// Print the string stored in buffer and
// character count
printf("string:\n%s\ncharacter count = %d\n", buffer, j);
// return 0;
}
void loop()
{
}
and what I got in the serial monitor:
string:
but I got no buffer contents! Any idea what happened to the buffer contents?
Re: Trouble getting a simple sketch working in Arudino IDE
Posted:
Mon Mar 11, 2019 8:51 pm
by mrburnette
Setup() is for initialization
Loop() is your main() with an eternal built-in loop
So, the correct way to construct your sketch is discussd here:
https://www.arduino.cc/en/tutorial/sketchThe Arduino IDE installs switch examples, too.