Page 1 of 1

Analog output for Knock Shield

Posted: 19 Dec 2019 00:45
by Christian_Bylund
Is it possible to implement an analog output for the Knock Shield?
Yes, just like we did for the Lambda Shield.

Image
Here is how to connect the RC-filter to the Arduino.

Image

This is the RC-filter used in the example.

To enable the output first we need to define the pin to be used.

Code: Select all

#define ANALOG_OUTPUT_PIN 3 /* Pin used for the PWM to the 0-1V analog output. */
Second we need an output proportional to the input.

Code: Select all

uint8_t analogOutput = map(adcValue_UA, 0, 1023, 0, 255);
analogWrite(ANALOG_OUTPUT_PIN, analogOutput);
Image
The RC-filtered signal (blue) and unfiltered PWM signal (red).

Download the updated example code from GitHub.