• Increase font size
  • Default font size
  • Decrease font size
  • default color
  • cyan color
  • red color

Arduino.TW樂園

Member Area
Arduino + Flash + 光敏電阻初體驗! PDF 列印 E-mail
作者是 xlinx   
週二, 05 十二月 2006 21:40

DEMO Video

1. 電路連接方式:

 2. code:


int potPin = 0;   // 宣告類比腳位輸入的PIN腳

int val = 0;      // 宣告變數Val = 0

int pin = 12;    



void setup() {  



   Serial.begin(9600);  //設定SerialPort的速度9600 = 9600bit/s

   pinMode(pin,OUTPUT);

 }



void loop() {  

  

    val = analogRead(potPin);     // 用analogRead()這個函式讀取特定腳位的數值到變數  

    Serial.println(val);            //印出數值在Serial.Monitor  

    digitalWrite(pin,HIGH);

    delay(val/10);                   //延遲讀入的時間為25ms

    digitalWrite(pin,LOW);

    delay(val/10);  

}

[程式碼下載]

3. 增加Serial.print(0,BYTE);


int potPin = 0;   // 宣告類比腳位輸入的PIN腳

int val = 0;      // 宣告變數Val = 0

int pin = 12;    



void setup() {  



   Serial.begin(9600);  //設定SerialPort的速度9600 = 9600bit/s

   pinMode(pin,OUTPUT);

 }



void loop() {  

  

    val = analogRead(potPin);     // 用analogRead()這個函式讀取特定腳位的數值到變數  

    Serial.print(val);            //印出數值在Serial.Monitor  

    Serial.println(0,BYTE);

    digitalWrite(pin,HIGH);

    delay(val/10);                   //延遲讀入的時間為25ms

    digitalWrite(pin,LOW);

    delay(val/10);  

}

 

[程式碼下載]

4. 加上flash

 


blog comments powered by Disqus
最近更新在 週六, 29 五月 2010 21:59