pwm问题
怎样用定值电阻代替电位器调节pwm这样也不行啊 。。。。。。电阻值都固定了。。。怎么调节 弘毅 发表于 2017-4-24 14:43
。。。。。。电阻值都固定了。。。怎么调节
我用pwm控制电机的转速,但我想一上电给电机一个固定转速,能用固定电阻代替 不太理解。。。如果上电给一个固定转速,setup部分写就好了,为什么要固定电阻? 弘毅 发表于 2017-4-25 17:12
不太理解。。。如果上电给一个固定转速,setup部分写就好了,为什么要固定电阻?
int analongPin=A0;
int temp;
void setup() {
pinMode(9,OUTPUT);
}
void loop() {
temp=analogRead(analongPin);
analogWrite(9,temp/4);
}
liujiajia 发表于 2017-4-25 17:53
int analongPin=A0;
int temp;
void setup() {
int temp =固定值
或者在setup给temp设置固定值。。。 int analongPin=A0;
int temp;
void setup() {
pinMode(9,OUTPUT);
}
void loop() {
temp=500;
analogWrite(9,temp/4);
}
:lol
页:
[1]