根据以下程序流程,写出KEY1按下返回1,否则返回0的C语言函数KEY_Scan。u8 KEY_Scan(void) { if(KEY按下) { delay_ms(10);//延时10-20ms,防抖。 if(KEY确实按下) { return KEY_Value; } return 无效值; }}
举一反三
- 中国大学MOOC: 以下Pair泛型类public class Pair<K, V> { public Pair(K key, V value) { this.key = key; this.value = value; } public K getKey(); { return key; } public V getValue(); { return value; } public void setKey(K key) { this.key = key; } public void setValue(V value) { this.value = value; } private K key; private V value;}经过类型擦除后,变成以下类public class Pair { public Pair(Object key, Object value) { this.key = key; this.value = value; } public Object getKey() { return key; } public Object getValue() { return value; } public void setKey(Object key) { this.key = key; } public void setValue(Object value) { this.value = value; } private Object key; private Object value;}
- voidScan_KEY(){if(digitalRead(KEY)==0){delay(20);if(digitalRead(KEY)==0){KEY_NUM=1;while(digitalRead(KEY)==0);}}}函数中delay(20);表示消除抖动()。
- 判断按键是否按下的编程程序正确的是( ) A: if(key==0){…..}else{ ……} B: if(key=0){…..}else{ ……} C: while(key==0){ ……} D: while(key=0){ ……}
- 等待按键按下后松开的语句是() A: while(key==0) B: if(key==0); C: while(key=0); D: if(key=0);
- 判断键盘中A键是否被按下的正确语句是( ) A: key='A'; B: key="A"; C: key=='A'; D: key=="A";