Go Down

Topic: printf on DUE (Read 1 time) previous topic - next topic

PoohDuino

Hello all,

I want printf support in my Due sketches and
have followed instructions as given at this link: http://playground.arduino.cc/Main/Printf
but I get compile failures ...
    '_FDEV_SETUP_WRITE' was not declared in this scope
    'fdev_setup_stream' was not declared in this scope

I have included stdio.h in the sketch (where the above are defined) but to no avail. If I change the
target board to, say, the Uno then the compile passes. What am I missing?

Thanks.

stimmer

It looks like stdout is already redirected to the programming port UART on the due - try this:
Code: [Select]
#include <stdio.h>

void setup() {
  Serial.begin(9600);
}

void loop() {
  printf("hello world!\n");
}



PoohDuino

Thank you. You are right it works!
Any ideas on how I can add floating point printf() support?

Thanks.

stimmer

Code: [Select]
#undef printf
#include <stdio.h>
void setup() {
  Serial.begin(9600);
}

float q=0.1;
void loop() {
  q+=0.1;
  printf("hello world! %f\n",q);
}

PoohDuino

Yes working again. Thanks.
Where are you getting all this wonderful information from?

Thanks again.

Go Up