DFRobot DFR0004 Manual - Halaman 5
Jelajahi secara online atau unduh pdf Manual untuk Perangkat Keras Komputer DFRobot DFR0004. DFRobot DFR0004 13 halaman. Dfrduino romeo-all in one controller
Juga untuk DFRobot DFR0004: Manual (11 halaman), Manual (16 halaman)
char start_msg[15] = {
"Start loop "};
int
adc_key_val[5] ={
30, 150, 360, 535, 760 };
int NUM_KEYS = 5;
int adc_key_in;
int key=-1;
int oldkey=-1;
void setup() {
pinMode(13, OUTPUT);
Serial.begin(9600);
/* Print that we made it here */
Serial.println(start_msg);
}
void loop()
{
adc_key_in = analogRead(7);
digitalWrite(13, HIGH);
/* get the key */
key = get_key(adc_key_in);
if (key != oldkey) {
delay(50);
adc_key_in = analogRead(7);
key = get_key(adc_key_in);
if (key != oldkey) {
oldkey = key;
if (key >=0){
Serial.println(adc_key_in, DEC);
Serial.println(msgs[key]);
}
}
//we'll use the debug LED to output a heartbeat
// read the value from the sensor
// convert into key press
// if keypress is detected
// wait for debounce time
// read the value from the sensor
// convert into key press