Hello everbody, i'm trying to control my dc motor with the "switch case" because how we know it, it's imposible to control the motor position w/out an enconder. how i'll not use it i tried to use the switch case how y'll see bellow:
void setup() {
// sets the pins as outputs:
pinMode(motor1Pin1, OUTPUT);
pinMode(motor1Pin2, OUTPUT);
pinMode(enable1Pin, OUTPUT);
Serial.begin(9600);
}
void loop() {
if (Serial.available() > 0) {
int comando = Serial.read();
Can you please post a schematic of your project?
Can you please tell us what model Arduino are you using?
What motor you are controlling?
What are you using as a motor driver?
Your topic has been moved to a more suitable location on the forum. Introductory Tutorials is for tutorials that e.g. you write, not for questions. Feel free to write a tutorial once you have solved your problem
this project is for a window, a mini window...that's why i'm using the dc motor, because the micro servo motor 9g can just reach 180º...how this window is a little big i decided to use a dc motor...
my microcontroller is an esp wrover and i'm using a ln289 driver...the h-brigde.
my all code is bellow /
// Motor A
int motor1Pin1 = 27;
int motor1Pin2 = 26;
int enable1Pin = 14;
const int freq = 1500;
const int pwmChannel = 0;
const int resolution = 8;
int dutyCycle = 200;
but the problem has been the dc motor dont breaking after the time that i want, this is why i thought that using delay the dc motor would start after my command, and break after a time...maybe 1 sec after
i need to be honest, i'm not undertandig why i would use this, because my code worked, the only problem is that i cant make my dc motor break when i want...even just when i use other switch case in te monitor. got it?
Now please edit your post #5, select all code and click the </> button to apply so-called code tags and next save your post. It makes it easier to read, easier to copy and prevents the forum software will display it correctly.