Hi there , i am wondering how to ramp a 12 volt dc motor to increase and decrease in speed randomly. Rather than go from 0 to 255 and down to zero. Eg from 0 to 255 then down to 100 back to 200 down to 50 etc i am using cryton mdda20 and library
thankyou in advance
my code as follows
//Initializing LED Pin
#include "CytronMotorDriver.h"
//int led_pin = 13;
CytronMD motor1(PWM_DIR, 3, 4); // PWM 1 = Pin 3, DIR 1 = Pin 4.
//CytronMD motor2(PWM_DIR, 9, 10); // PWM 2 = Pin 9, DIR 2 = Pin 10.
void setup() {
Serial.begin (9600);
}
void loop() {
//ramping the motor
for (int i = 0; i < 255; i++) {
move_motor1(i);
Serial.print("int up........");
Serial.println(i);
//delay(5);
}
for (int i = 255; i > 0; i--) {
//
Serial.print("int down........");
Serial.println(i);
move_motor1(i);
//delay(5);
}
}
void move_motor1(int i)
{
motor1.setSpeed( i);
}