2019年6月12日 星期三

relay + motor






































#define ctrlPin 8
int delaytime=1000;
void setup()
{
  // put your setup code here, to run once:
  pinMode(ctrlPin,OUTPUT);
}

void loop()
{
  // put your main code here, to run repeatedly:
  digitalWrite(ctrlPin,HIGH);delay(delaytime);
  digitalWrite(ctrlPin,LOW);delay(delaytime);
}
例:增加到130,馬達開始轉到255,0~125馬達不會轉
2.5V以下不會轉,2.5V才會轉
int relay_input_pin = 13;
int rotate = 0;   
int fadeAmount = 5;   
void setup()
{
  pinMode(relay_input_pin, OUTPUT);
  Serial.begin(9600);
}
void loop()
{
  analogWrite(relay_input_pin, rotate);
  Serial.println(rotate);
  rotate = rotate + fadeAmount;
  if (rotate >= 255) rotate = 0;
  delay(1000);
}

沒有留言:

張貼留言

algorithm

 #include <iostream> #include <string.h> using namespace std; int main(int argc, char** argv)  { for(int j=2;j<=100;j++)//j...