Arduino uno with MD10c shield

LINIX Brushless, VEXTA Brushless, RC Servo, DC Geared, Linear, Stepper, Tamiya.....

Arduino uno with MD10c shield

Postby mektekcg » Mon Oct 31, 2016 8:53 pm

Hi All,

First, thank you for your time.

I have an Arduino UNO R3 with a Cytron MD10C R2. The buttons run the motor nicely. The source code on the MD10C runs the motor in both directions as it should. I would like to ask for code that runs the motor for a specific time or number of revolutions, assuming revolutions would negate an encoder, time based code would be optimal. I will trigger the start of the motor with a switched (digital) input, the motor will run for a specific time and stop, upon reset of the board I would like to run the motor in the reverse direction for the same time interval so as to get back to it's position at start of program. Any assistance would be greatly appreciated.
mektekcg
Greenhorn
 
Posts: 2
Joined: Mon Oct 31, 2016 8:32 pm
Location: Charleston SC

Re: Arduino uno with MD10c shield

Postby mektekcg » Tue Nov 01, 2016 4:35 am

This gets me turning, I just need to stop based on time, and incorporate a single input.

// definitions
#define pwm 9
#define dir 7
void setup()
{
pinMode(pwm,OUTPUT); // set pwm as output
pinMode(dir,OUTPUT); // set dir as output
}
void loop(){
int pwm_value=0;
int pinPwm = 9;
int pinDir = 7;
digitalWrite(dir,LOW); // set DIR pin HIGH or LOW
for
(pwm_value=0;pwm_value<256;pwm_value++){
analogWrite(pwm,pwm_value); //increase PWM in every 0.1 sec
delay(10);
}
while(1) continue; //continue,terminate loop;
}
mektekcg
Greenhorn
 
Posts: 2
Joined: Mon Oct 31, 2016 8:32 pm
Location: Charleston SC


Return to DC Motor

Who is online

Users browsing this forum: No registered users and 7 guests

cron