Last active
December 11, 2015 08:08
-
-
Save pureexe/4570887 to your computer and use it in GitHub Desktop.
โค้ดของภูมิ Lamplife ipst microbox [Update 19/01/2556 12:05]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| *** หมายเหตุ สวิตซ์ ให้ต่อที่ Pa 1 | |
| ไฟใหญ่ ให้ต่อที่ Pd 0 | |
| ไฟเล็ก ให้ต่อที่ Pd 1, Pd 2 | |
| **/ | |
| #include<ipst.h> | |
| int pin_a(int port) | |
| { | |
| if(!in_a(port)) | |
| { | |
| while(!in_a(port)); | |
| return 0; | |
| } | |
| else | |
| return 1; | |
| } | |
| int blink_state=0,isblink=0,i,round_count; | |
| void blink () | |
| { | |
| if(blink_state) | |
| for(i=1;i<3;i++) | |
| out_d(i,0); | |
| else | |
| for(i=1;i<3;i++) | |
| out_d(i,1); | |
| } | |
| int main() | |
| { | |
| while(1) | |
| { | |
| if(!pin_a(1)) | |
| { | |
| round_count++; | |
| if(round_count%3==0) | |
| { | |
| isblink=0; | |
| blink_state=0; | |
| for(i=0;i<3;i++) | |
| out_d(i,0); | |
| } | |
| if(round_count%3==1) | |
| out_d(o,1); | |
| if(round_count%3==2) | |
| { | |
| out_d (0,0) | |
| isblink=1; | |
| } | |
| } | |
| if(isblink) | |
| { | |
| blink(); | |
| if(blink_state) | |
| blink_state=0; | |
| else | |
| blink_state=1; | |
| sleep(100); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment