• Arduino 各种模块篇 震动模块 vibrator module


    The vibrator I got works at the voltage ranging from 3.3V ~ 5.5V

    Gvib.jpg

    I want to make it vibrate variably.

    So I planned to test in 2 different ways.

    1) analog valtage supply

    2) PWM full valtage supply

    Here's the test situations and codes

    1) analog valtage supply

    int vibratorPin=A1; // vibrator on A1
    int i=0;
    void setup()
    {
      Serial.begin(9600);
      //pinMode(vibratorPin,OUTPUT);
      pinMode(10,OUTPUT); // Full valtage Pin
      digitalWrite(10,HIGH);
    }
    void loop()
    {
      for(i=0; i < 256; i=i+1)
      //Acutally the vibrator works from on i = 130
      //analog doesn't work so ideally
      {
        analogWrite(vibratorPin,i); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
        Serial.print("vibration value");
        Serial.print("	");
        Serial.println(i);
        delay(50);
      }
      i=0;
    }

    --analysis : only when "i" goes up more than 130 , the vibrator begins to work.

    Also not very different from if just give it full voltage supply. ( digital Pin 10 as a control experiment here )

    2) PWM full voltage supply

    int vibratorPin=9; // vibrator on Pin 9
    int i=0;
    void setup()
    {
      Serial.begin(9600);
      pinMode(vibratorPin,OUTPUT);
      pinMode(10,OUTPUT); // Full valtage Pin
      digitalWrite(10,HIGH);
    }
    void loop()
    {
      for(i=0; i < 256; i++)
      //Acutally the vibrator works from on i = 130
      //analog doesn't work so ideally
      {
        digitalWrite(vibratorPin,i); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
        Serial.print("vibration value");
        Serial.print("	");
        Serial.println(i);
        delay(50);
      }
      i=0;
    }

    --effect analysis:

    Initially when variable "i" ranges from 0 to 100, I can feel the module vibrates dynamically clearly. But after "i" goes up to more than 100, I feel it all the same, which means "100" is no different from "200" for this instance.

    So I re-code it.

    int vibratorPin=9; // vibrator on Pin 9
    int i=0;
    void setup()
    {
      Serial.begin(9600);
      pinMode(vibratorPin,OUTPUT);
      pinMode(10,OUTPUT); // Full valtage Pin
      digitalWrite(10,HIGH);
    }
    void loop()
    {
      for(i=0; i < 5; i=i+1) // Here is the part i changed , but still not different from previous one
      //Acutally the vibrator works from on i = 130
      //analog doesn't work so ideally
      {
        digitalWrite(vibratorPin,i); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
        Serial.print("vibration value");
        Serial.print("	");
        Serial.println(i);
        delay(500);
      }
      i=0;
    }

    #############

    Summery:

    Above all, so for  this vibrator module, please don't think to use it like a vibrator variably.

    Buy a digital one! Haha! Gonna get one!

  • 相关阅读:
    vim7.1在windows下的编码设置[转]
    Swashbuckle(6.2.3)【Swagger(3.0)】 第一节
    Git命令集合
    ABP Framework(5.0.0rc) 第一节
    /var/lib/docker/overlay2 占用很大,清理Docker占用的磁盘空间,迁移 /var/lib/docker 目录
    WPF中解决内存泄露的几点提示与解决方法
    用C#读取docx文件
    C#启动单个实例
    WPF学习心得(1):WPF进行动画后不能改变相对应的属性问题的解决
    [转]使WPF程序应用预置的控件风格, 如Aero, Luna, Royale, Classic等
  • 原文地址:https://www.cnblogs.com/spaceship9/p/3425670.html
Copyright © 2020-2023  润新知