Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ใช้บอร์ด ATX2 เพื่อทดสอบ ZX-LED ที่ต่อกับขา 24 จะกะพริบทุกๆ 0.2 วินาที
- // และทดสอบ ZX-Switch01 ที่ต่อกับขา30 ให้แสดงหน้าจอคำว่า Press เมื่อกดสวิตช์
- // ใช้ millis แทน delay เพื่อทำงาน 2 อย่างพร้อมกันได้โดยไม่ต้องรอ
- #include <ATX2.h>
- int x=0,t;
- void setup(){
- XIO();
- t=millis();
- setTextColor(GLCD_YELLOW);
- setTextSize(3);
- glcdMode(1);
- //pinMode(30,INPUT_PULLUP);
- }
- void loop(){
- if (in(30)==0){
- glcd(2,2,"Press");
- }
- else {glcd(2,3," ");}
- if (millis()>t+200){
- if (x==0){out(24,1);x=1;}
- else{out(24,0);x=0;}
- t=millis();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment