Running three Peristaltic pumps off my Mega 2560 with a 16x2 LCD display Shield

So I am working on a project to control three peristaltic pumps using my Mega 2560 Arduino and LCD display. Ive got the pumps Running, but i am having trouble implementing the interrupts to increase the speed of the pumps. Im not sure where to go from here. If anyone has any advice or ideas it would be appreciated.

I have attached what I have so far below:

Motor_Control1.ino (2.13 KB)

Ive got the pumps Running, but i am having trouble implementing the interrupts to increase the speed of the pumps. Im not sure where to go from here. If anyone has any advice or ideas it would be appreciated.

Can you supply a link to the data sheets for the pumps?

I’m thinking that a better approach for you will be to use analogWrite() to control the pump speed instead of using the digitalWrite() pulsing that is in your present code and messing about with the timer registers.

It is better to post your code using code tags, rather than attaching. More people will read it.

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
int motorOn = 41;
int motorControl=0;
int speedControl=0;
void setup() {


  Serial.begin(9600);
 delay(50);
 TCCR1A = B0011001;    
 TCCR1B = B0100010;
 TCCR1C = B0000000;
 TIMSK1 = B0000010;  
 //ITV1  = B0000010;
 OCR1A = 1;      //Pause between pulses in us
 OCR1B = 100;       //Pulse Length in us
 TCNT1 = 0;
 pinMode(41, OUTPUT); //this produces a pulse on pin 10;
 



  
  // set up the LCD's number of columns and rows:
  pinMode(motorOn, OUTPUT);
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.setCursor(0, 0);
  lcd.print("LCD Key Shield");
  lcd.setCursor(0, 1);
  lcd.print("Press Key:");
}



ISR(TIMER1_COMPA_vect)  // Timer-1 OC1A Match interrupt handler
{
 //No need to do anything here other than change the pause between pulses
// by changing the value of OC1A
};



void loop() {

if (motorControl == 1) {
    
    digitalWrite(motorOn, HIGH);
    delay(1);
    digitalWrite(motorOn, LOW);
    digitalWrite(motorOn, HIGH);
    digitalWrite(motorOn, LOW);
    digitalWrite(motorOn, HIGH);
    digitalWrite(motorOn, LOW);
    digitalWrite(motorOn, HIGH);
}

if (speedControl == 10) {

  digitalWrite( motorOn, HIGH);
  delay(1);
  digitalWrite(motorOn, LOW);
  digitalWrite(motorOn, LOW);
  digitalWrite(motorOn, HIGH);
}

if (motorControl == 0) {

  digitalWrite(motorOn, LOW);
}



// BUTTON SECTION
  // BUTTON SETUP
  int x;
  x = analogRead (0);

  if (x < 60) { // THIS IS RIGHT BUTTON WHICH IS MOTOR ON
    lcd.clear();
    lcd.setCursor(4, 0);
    lcd.print ( "Motor On");
   motorControl=1;
  }
  else if (x < 200) {  //  THIS THE UP BUTTON WHICH IS MOTOR OFF
    lcd.clear();
    lcd.setCursor(4, 0);
    lcd.print ("Motor OFF");
    motorControl=0;
  }
  else if (x < 400) {  //  
    lcd.clear();
    lcd.setCursor(2, 0);
    lcd.print ("Motor slower");
    speedControl=10;
    
  // InterruptTimerOneValue = InterruptTimerOneValue + 1
  }
  else if (x < 600) {
    lcd.print ("Left  ");
  }
  else if (x < 800) {
    lcd.print ("Select");
  }

// END OF BUTTON SECTION
  
}

I can't seem to find the pumps data sheets anywhere. It is a Peristaltic Pump with a 42 Stepper motor by Grothen if that helps at all. Im pretty new to all this stuff, but i appreciate the help. I'm going to try replacing my digitalWrite() with an analogWrite() and see how it works.

It is a Peristaltic Pump with a 42 Stepper motor by Grothen

I'm going to try replacing my digitalWrite() with an analogWrite() and see how it works.

If they are steppers, that's not what you need. I incorrectly assumed they were geared dc motors.

Take a look at the Stepper Motor Basics tutorial.