23 lines
374 B
C++
23 lines
374 B
C++
#include "avr.h"
|
|
#include "adc.h"
|
|
#include "util.h"
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
int getButton() {
|
|
uint16_t val = getADCValue(7);
|
|
|
|
if(val < 144) return 5;
|
|
if(val < 228) return 4;
|
|
if(val < 304) return 3;
|
|
if(val < 376) return 2;
|
|
if(val < 600) return 1;
|
|
|
|
return 0;
|
|
}
|
|
|
|
void waitForButton(int i) {
|
|
while(getButton() != CLAMP(0, i, 5));
|
|
while(getButton() != 0);
|
|
}
|