This commit is contained in:
2025-11-02 19:18:29 +01:00
parent d3905aa142
commit 84065e09e1

View File

@@ -19,9 +19,6 @@ uint16_t ADC_read(uint8_t channel) {
// Wait for conversion to complete
while (!(ADC1.INTFLAGS & ADC_RESRDY_bm));
//// Clear the interrupt flag
//ADC0.CH0.INTFLAGS = ADC_CH_CHIF_bm;
// Read the result
return ADC1.RES; // Return the 12-bit result
}
@@ -32,13 +29,14 @@ int main(void){
PORTB.DIRSET = 1 << 3;
PORTA.PIN4CTRL |= PORT_PULLUPEN_bm;
PORTC.PIN1CTRL |= PORT_PULLUPEN_bm;
ADC_init();
uint8_t suck = 0;
uint16_t cooldown = 0;
while(1){
suck = !(PORTA.IN & (1<<4));
if(suck){
static uint16_t cooldown = 0;
uint8_t suck = !(PORTA.IN & (1<<4));
uint8_t mode = !(PORTC.IN & (1<<1));
if(suck ^ mode){
static uint8_t timer = 0;
static uint16_t duty = 0;