Merhaba. Arduino üzerinden 2 adet butonlu sağa ve sola döndürülebilen bir DC motor yaptım. Fakat ne kadar döneceğinin süresini ayarlamayı bilmiyorum.
Benim kullandığım kod bu;
Nasıl bir kod eklersem DC motorun dönmesini süreli hale getirebilirim?
Benim kullandığım kod bu;
Kod:
#İnclude <Keypad.h>
İnt motorpin1 = 5;
İnt motorpin2 = 6;
Const byte rows = 2;
Const byte cols = 1;
Char hexakeys[ROWS][COLS] = {{'2'}, {'1'}};
Byte rowpins[ROWS] = {3, 2};
Byte colpins[COLS] = {4};
Keypad customkeypad = keypad( makekeymap(hexakeys), rowpins, colpins, rows, cols);
Void setup()
{
Serial. Begin(9600);
}
Void loop()
{
Char customkey = customKeypad.getKey();
Switch (customkey)
{
Case '1':
Serial. Println("rotates to left");
rotateLeft();
Break;
Case '2':
Serial. Println("rotates to right");
rotateRight();
Break;
}
}
Void rotateLeft()
{
Digitalwrite(motorpin1, hıgh);
Digitalwrite(motorpin2, Low);
}
Void rotateRight(){
Digitalwrite(motorpin2, hıgh);
Digitalwrite(motorpin1, Low);
}
Nasıl bir kod eklersem DC motorun dönmesini süreli hale getirebilirim?