Skip to content

Commit

Permalink
Added ADC delay for reliable read of high-impedance inputs. dontsovcm…
Browse files Browse the repository at this point in the history
  • Loading branch information
svpcom committed Nov 12, 2021
1 parent 7b23385 commit ae00e31
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Attiny85/src/counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ struct CounterB
inline uint16_t aRead()
{
PORTB |= _BV(_pin); // INPUT_PULLUP
uint16_t ret = analogRead(_apin); // в TinyCore там работа с битами, оптимально
analogRead(_apin); // Switch MUX to channel and discard the read
delayMicroseconds(1000); // Wait for ADC S/H capacitor to charge
uint16_t ret = analogRead(_apin); // Read ADC
PORTB &= ~_BV(_pin); // INPUT
return ret;
}
Expand Down Expand Up @@ -136,4 +138,4 @@ struct ButtonB
};


#endif
#endif

0 comments on commit ae00e31

Please sign in to comment.