PowenKo > Hardware > Arduino> Begin >繼電器控制實驗

February 7, 2012   ·   0 Comments

Screen Shot 2012-02-07 at 3.03.02 PM


int pin = 7;
int incomingByte = 0;
void setup() { 
  Serial.begin(9600);
  pinMode(pin,OUTPUT);
} 
void loop () { 
  if(Serial.available() >0){
    incomingByte = Serial.read();
    Serial.print("ON!");
    Serial.println(incomingByte);
    if(incomingByte == 65){  // A
       digitalWrite(pin,HIGH);
       delay(150);
    }else{
      digitalWrite(pin,LOW);
      delay(150);
    }
  } 
}



Read More: http://arduino.tw/allarticlesindex/2009-09-06-18-37-08/225-relay.html#ixzz1ljwfpuSB 
Arduino.TW 
Under Creative Commons License: Attribution Non-Commercial No Derivatives
shareShare on FacebookShare on Google+Share on LinkedInEmail this to someonePrint this pageBuffer this pageDigg thisFlattr the authorShare on RedditPin on PinterestShare on StumbleUponShare on TumblrTweet about this on Twitter

By


Readers Comments (0)


You must be logged in to post a comment.

PowenKo’s Online Store

powenko_arduinoBook
Hardware22

Hardware

Amazon

adsbygoogle

Recent Posts

Categories

Amazon