PowenKo > Hardware > Arduino > Photoresistor

February 7, 2012   ·   0 Comments

Screen Shot 2012-02-07 at 3.34.02 PM

接法如上圖:

電阻:1K歐姆 棕黑紅

範例程式碼:



int potPin = 2;    //設定讀入的腳位
int val = 0;      

void setup() {
  Serial.begin(9600);
}

void loop() {
  val = analogRead(potPin);   
  Serial.print(val);    //將讀取的數值顯示在serialmonitor
}




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