Analog-to-digital converter code for Due

Hello all,

i want to convert an external digital signal using DAC1 in Due. i wrote the code to do this function but there is no analog signal in the analog output in pin DAC1.

const int InputDigitalPin = 24;// digital input pin 24

void setup()
{
analogWriteResolution(12); // 12 bits resolution
pinMode(InputDigitalPin,INPUT); // assigned pin 24 as input
Serial. begin(9400);

}

void loop()
{
int b;
b = digitalRead(24);// read digital pin 24 and put it in varible b
Serial.println(b);

analogWrite(DAC1, b); // output analog signal on pin DAC1
}

i am sure i am missing something, could anyone help me out and tell me what modification i should do in the sketch?

best wishes,

M

I don't know about the rest of the code , but this isn't right.

Serial. begin(9400);

try 9600.

thanks, i don't know how i miss that.

M