//51單片機(jī) //p3.5口接燈的陰極端,按鍵劃分接p2.0 p2.1 #include #define uchar unsigned char #define uint unsigned int #define LED_ON 0 #define LED_OFF 1 sbit led = P3^5; sbit key_up = P2^0; sbit key_down = P2^1;
{ key_up = 1; key_down = 1; led = 1;
{ if(key_down) { if(key_up) { led = LED_OFF; } else { led = LED_ON; } } else { if(key_up) { led = LED_ON; } else { led = LED_OFF; } } } } |
|
來(lái)自: 快樂(lè)讀書(shū)法 > 《程序?qū)嵗?/a>