From 9d74b0f6a55d33aee7c5be4d31b0b35b40d359ba Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Fri, 29 Oct 2021 22:19:23 +0200 Subject: [PATCH] set pinMode analog --- MotorDriver.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MotorDriver.cpp b/MotorDriver.cpp index 8959f42..11d56d8 100644 --- a/MotorDriver.cpp +++ b/MotorDriver.cpp @@ -58,12 +58,13 @@ MotorDriver::MotorDriver(byte power_pin, byte signal_pin, byte signal_pin2, int8 currentPin=current_pin; if (currentPin!=UNUSED_PIN) { - pinMode(currentPin, INPUT); #if defined(ARDUINO_ARCH_ESP32) + pinMode(currentPin, ANALOG); adc1_config_width(ADC_WIDTH_BIT_12); adc1_config_channel_atten(pinToADC1Channel(currentPin),ADC_ATTEN_DB_11); senseOffset = adc1_get_raw(pinToADC1Channel(currentPin)); #else + pinMode(currentPin, INPUT); senseOffset=analogRead(currentPin); // value of sensor at zero current #endif }