2013年4月28日 星期日

week 11. actuators

servo motor

wooden mirror

Audience [openFrameworks]


http://lcchen.dcilab.hinet.net/spacenews/2005/05112001.htm



input sample: File -> Examples -> Digital -> DigitalInputPullup

output servo sample: File -> Examples -> Servo ->Sweep





3 則留言:

  1. 1. downloading http://playground.arduino.cc//Main/CapacitiveSensor?from=Main.CapSense

    2. arduino-libraries-CapacitiveSensor-3e33f75.zip

    3. CapacitiveSensor folder copy to my document >>> arduino >> libraries

    ex: C:\Users\IDC\Documents\Arduino

    4. restart Arduino IDE check the Example CapacitiveSensorSketch

    回覆刪除
  2. //touch with servo motor
    /*
    * CapitiveSense Library Demo Sketch
    * Paul Badger 2008
    * Uses a high value resistor e.g. 10M between send pin and receive pin
    * Resistor effects sensitivity, experiment with values, 50K - 50M. Larger resistor values yield larger sensor values.
    * Receive pin is the sensor pin - try different amounts of foil/metal on this pin
    */
    #include
    #include //!!!!!!!!!!!!
    Servo myservo; //!!!!!!!!!!!!
    int tttt = 3000 ; //!!!!!!!!!!!!
    CapacitiveSensor cs_4_2 = CapacitiveSensor(4,2); // 10M resistor between pins 4 & 2, pin 2 is sensor pin, add a wire and or foil if desired

    void setup()
    {
    myservo.attach(9); //!!!!!!!!!!!!
    cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off autocalibrate on channel 1 - just as an example
    Serial.begin(9600);
    }

    void loop()
    {
    long start = millis();
    long total1 = cs_4_2.capacitiveSensor(30);
    Serial.print(millis() - start); // check on performance in milliseconds
    Serial.print("\t"); // tab character for debug windown spacing
    Serial.println(total1); // print sensor output 1

    if(total1 > tttt) //!!!!!!!!!!!!
    {
    myservo.write(90); //!!!!!!!!!!!!
    }
    if(total1 <= tttt) //!!!!!!!!!!!!
    {
    myservo.write(0); //!!!!!!!!!!!!
    }
    delay(10); // arbitrary delay to limit data to serial port
    }

    回覆刪除
  3. 練習參考:
    1.按鍵按下時,LED發光,再按下時,LED熄滅
    2.按鍵按下時,喇叭嗶一聲 tone();
    3.按鍵按下時,聲音啟動,再按下時,聲音解除
    4.按鍵按下時,led顆數顯示器往上數
    5.按鍵按下時,LED漸亮,再按下時,LED漸暗
    6.按鍵按下時,亮,再按下時,暗
    7.按鍵按下時,led越閃越快
    8.傾斜開關動作時,LED發光,再按下時,LED熄滅
    9.可變電阻旋轉時,LED漸亮
    10.可變電阻旋轉時,LED越閃越快
    11.光敏電阻受光越亮時,LED漸亮
    12.光敏電阻受光越亮時,馬達越轉越快

    回覆刪除