The vibrator I got works at the voltage ranging from 3.3V ~ 5.5V
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=;
void setup()
{
Serial.begin();
//pinMode(vibratorPin,OUTPUT);
pinMode(,OUTPUT); // Full valtage Pin
digitalWrite(,HIGH);
}
void loop()
{
for(i=; i < ; i=i+)
//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("\t");
Serial.println(i);
delay();
}
i=;
}
--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=; // vibrator on Pin 9
int i=;
void setup()
{
Serial.begin();
pinMode(vibratorPin,OUTPUT);
pinMode(,OUTPUT); // Full valtage Pin
digitalWrite(,HIGH);
}
void loop()
{
for(i=; i < ; 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("\t");
Serial.println(i);
delay();
}
i=;
}
--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=; // vibrator on Pin 9
int i=;
void setup()
{
Serial.begin();
pinMode(vibratorPin,OUTPUT);
pinMode(,OUTPUT); // Full valtage Pin
digitalWrite(,HIGH);
}
void loop()
{
for(i=; i < ; i=i+) // 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("\t");
Serial.println(i);
delay();
}
i=;
}
#############
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!