Changes between Version 21 and Version 22 of wade/embedded/arduino/example/temp


Ignore:
Timestamp:
Jun 7, 2013, 11:17:19 AM (11 years ago)
Author:
wade
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • wade/embedded/arduino/example/temp

    v21 v22  
    538538}}}
    539539
     540= 程式十:按鍵輸入 =
     541{{{
     542int led = 13;
     543
     544int lighttpye = 0;
     545int switchbutton=1;
     546
     547void setup() {
     548  pinMode(2, INPUT);
     549  digitalWrite(2, HIGH);
     550  Serial.begin(9600);
     551  pinMode(led, OUTPUT);
     552}
     553void loop() {
     554
     555int input1 = digitalRead(2);
     556Serial.println(input1);
     557delay(300);
     558
     559if(switchbutton!=input1){
     560  if(input1!=0){
     561    if(lighttpye!=0){
     562      digitalWrite(led, HIGH);
     563      lighttpye=0;
     564    }else{
     565      digitalWrite(led, LOW);
     566    lighttpye=1;
     567  }}
     568
     569switchbutton=input1;
     570
     571}
     572}
     573}}}
     574
    540575[[Image(LED8x8-2.png)]]