KRITSADA

Test ZX-Switch and ZX-LED on ATX2

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