Programming: Controlling a Pin Using an ADC Value

The LED is connected to pin 0 on PORTD which is controlled by values from the ADC. The LED is actually representing a vacuum pump, so when the pressure sensor that is connected to the ADC passes a high threshold that will turn off the motor (pin to low) and if the ADC passes a low threshold, the motor will turn on (pin high). This will keep a vacuum in the tank between these two thresholds.



#include #include "MrLCD.h" #include int static volatile InchesOfHg = 0; int main(void) { InitializeMrLCD(); Send_A_StringToMrLCDWithLocation(1, 1, "Inches of Hg:"); DDRD |= 1< 25) enoughVacuum = 1; if (InchesOfHg < 15) enoughVacuum = 0; if (enoughVacuum == 0) PORTD |= 1<
Back to blog

Leave a comment

Please note, comments need to be approved before they are published.