DFRobot DFR0004 Manuale - Pagina 7
Sfoglia online o scarica il pdf Manuale per Hardware del computer DFRobot DFR0004. DFRobot DFR0004 16. Dfrduino romeo-all in one controller
Anche per DFRobot DFR0004: Manuale (13 pagine), Manuale (11 pagine)
2018/11/27
https://www.dfrobot.com/wiki/index.php/DFRduino_Romeo-All_in_one_Controller_V1.1(SKU:DFR0004)
DFRduino Romeo-All in one Controller V1.1(SKU:DFR0004) - DFRobot Electronic Product Wiki and Tutorial: Arduino and Robot Wiki-DFRobot.com
char msgs[5][15] = {
"Right Key OK ",
"Up Key OK
",
"Down Key OK ",
"Left Key OK ",
"Select Key OK" };
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);
/ / w e ' l l u s e t h e d e b u g L E D t o o u t p u t a h e a r t b e a t
Serial.begin(9600);
/ * P r i n t t h a t w e m a d e i t h e r e * /
Serial.println(start_msg);
}
void loop()
{
adc_key_in = analogRead(7);
digitalWrite(13, HIGH);
/ * g e t t h e k e y * /
key = get_key(adc_key_in);
(key != oldkey) {
i f
/ / i f k e y p r e s s i s d e t e c t e d
delay(50);
/ / w a i t f o r d e b o u n c e t i m e
adc_key_in = analogRead(7);
key = get_key(adc_key_in);
(key != oldkey) {
i f
oldkey = key;
(key >=0){
i f
Serial.println(adc_key_in, DEC);
Serial.println(msgs[key]);
}
}
/ / r e a d t h e v a l u e f r o m t h e s e n s o r
/ / c o n v e r t i n t o k e y p r e s s
/ / r e a d t h e v a l u e f r o m t h e s e n s o r
/ / c o n v e r t i n t o k e y p r e s s
7/16