โพสต์26 มิ.ย. 2558 00:52โดยอนุสรณ์ จันทสุข
[
อัปเดต 26 มิ.ย. 2558 05:59
]
อุปกรณ์ 1. บอร์ด IPST-MicroBox++ 2. ZX-SWITCH หรือ ZX-Switch01 3. ZX-LED
การเชื่อมต่ออุปกรณ์
1. ต่อ ZX-SWITCH หรือ ZX-Switch01 ที่พอร์ต PA3 และ PA5 2. ต่อ ZX-LED ที่พอร์ต PD7
ตัวอย่างการใช้ปุ่ม Switch ตัวเดียวเปิดไฟ
1 #include <ipst.h> // include file for IPST-SE
2 void setup()
3 {
4 lcd("BT1->On#nPress SW1->Next");
5 sw1_press();
6 lcd("#c");
7 lcd("Lab Botton");
8 }
9
10 void loop()
11 {
12 int bt=analogRead(PA3);
13 if(bt==1){
14 digitalWrite(PD7,1);
15 } else {
16 digitalWrite(PD7,0);
17 }
18 }
ตัวอย่างการใช้ปุ่ม Switch ตัวเดียวเปิดปิดไฟ 1 #include <ipst.h> // include file for IPST-SE
2 void setup()
3 {
4 lcd("BT1->On-Off#nPress SW1->Next");
5 sw1_press();
6 lcd("#c");
7 lcd("Lab Botton");
8 }
9
10 void loop()
11 {
12 int bt=analogRead(PA3);
13 if(bt==1){
14 delay(250);
15 int x=0;
16 while(x==0)
17 {
18 bt=analogRead(PA3);
19 digitalWrite(PD7,1);
20 if(bt==1){
21 delay(250);
22 digitalWrite(PD7,0);
23 x=1;
24 }
25 }
26 }
27 }
ตัวอย่างการใช้ปุ่ม Switch 2 เดียวเปิดปิดไฟ 1 #include <ipst.h> // include file for IPST-SE
2 void setup()
3 {
4 lcd("BT1->On BT2->Off#nPress SW1->Next");
5 sw1_press();
6 lcd("#c");
7 lcd("Lab Botton");
8 }
9
10 void loop()
11 {
12 int bt1=analogRead(PA3);
13 int bt2=analogRead(PA5);
14 if(bt1==1){
15 digitalWrite(PD7,1);
16 }
17 if(bt2==1){
18 digitalWrite(PD7,0);
19 }
|
|