菜单
  

    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. 计算机辅助工艺规划CAPP系...

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

  5. 医院信息系统的云计算英文文献和中文翻译

  6. 计算机辅助工程设计重型...

  7. 板材矫直技术的计算机辅...

  8. 十二层带中心支撑钢结构...

  9. 当代大学生慈善意识研究+文献综述

  10. 乳业同业并购式全产业链...

  11. 河岸冲刷和泥沙淤积的监测国内外研究现状

  12. 大众媒体对公共政策制定的影响

  13. 电站锅炉暖风器设计任务书

  14. java+mysql车辆管理系统的设计+源代码

  15. 酸性水汽提装置总汽提塔设计+CAD图纸

  16. 中考体育项目与体育教学合理结合的研究

  17. 杂拟谷盗体内共生菌沃尔...

  

About

751论文网手机版...

主页:http://www.751com.cn

关闭返回