菜单
  

    Figure 5-10. The actual Arduino-based servo motor controller prototype

          To make the servo motor stationary on the solderless breadboard, a small jumper wire is secured across its wiring pigtail, as seen in Figure 5-10 on the right.

    Listing 5-1. The Servo Sweep Sketch

    // Sweep
    // by BARRAGAN  <http://barraganstudio.com>
    // This  example code is in the  public domain.
    #include<Servo.h>
    Servo myservo; // create  servo object  to  control a servo
                            // a maximum  of  eight servo objects  can be created
    int pos = 0;    // variable to  store  the  servo position
    void  setup()
    {
    myservo.attach(9); // attaches  the  servo on pin  9 to  the  servo object
    }
    void  loop()
    {
    for(pos = 0;  pos < 180; pos += 1)  // goes from 0 degrees to   
                                                              180degrees
    {    // in steps  of  1 degree
    myservo.write(pos); // tell servo to  go to  position in variable  'pos'
    delay(15);    //waits  15 ms  for the  servo to  reach the position
    }
    for(pos = 180; pos >= 1;  pos- = 1)     // goes from 180 degrees to
                                                                 0 degrees
    {
    myservo.write(pos);        // tell servo to  go to  position in variable 'pos' delay(15);    // waits  15 ms  for the  servo to  reach the position
    }
    }
    The Sweep sketch shown in Listing 5-1 is located in the ArduinoIDE at File→Examples→ Servo→ Sweep. Figure 5-11 shows the Sweep sketch within the Examples directory. When you upload the code to the Arduino computational platform, the servo motor begins to sweep between the established rotational angles of 0° to 180°. As mentioned, this sweep motion is continuous.
    Figure 5-11. Obtaining the Sweep sketch within the Arduino-Processing IDE
    Physical Computing: A Servo Motor with a Potentiometer
    If you add a potentiometer to the servo setup you have now, you can accommodate easy human interaction with the electromechanical components. By adding a potentiometer, manual control of the servo motor is possible. The potentiometer allows the servo motor’s angular position to be dialed in precisely. By rotating the potentiometer’s shaft (wiper arm), the servo motor’s degree of motion can be changed. Discrete angles such as 35°, 45°, 60°, and 110° can easily be dialed in using the potentiometer. The wiring to the Arduino’s PCB inline header connectors is accomplished as shown in Figure 5-12. The circuit schematic diagram is illustrated in Figure 5-13 with the actual prototype shown in Figure 5-14. The sketch for controlling the servo motor with
    a potentiometer is obtained from the Arduino-Processing IDE by clicking File → Examples → Servo →Knob. Figure 5-15 shows the Knob sketch within the Examples directory. The Knob sketch is shown in Listing 5-2.
  1. 上一篇:拉丝机英文文献和中文翻译
  2. 下一篇:冲压模具英文参考文献和中文翻译
  1. 智能城市物流云计算模型英文文献和中文翻译

  2. 云计算服务英文文献和中文翻译

  3. 直流电机英文文献和中文翻译

  4. 电-气动驱动的垂直计算机...

  5. 金属板料冲压模具计算机...

  6. 计算机辅助工艺规划CAPP系...

  7. 零件识别的计算机辅助装...

  8. 浅析中国古代宗法制度

  9. 现代简约美式风格在室内家装中的运用

  10. 高警觉工作人群的元情绪...

  11. 江苏省某高中学生体质现状的调查研究

  12. g-C3N4光催化剂的制备和光催化性能研究

  13. 巴金《激流三部曲》高觉新的悲剧命运

  14. C++最短路径算法研究和程序设计

  15. 中国传统元素在游戏角色...

  16. NFC协议物理层的软件实现+文献综述

  17. 上市公司股权结构对经营绩效的影响研究

  

About

优尔论文网手机版...

主页:http://www.youerw.com

关闭返回