Using multiple Hall effect sensors for RPM on CVT shafts HELP CODING

I am currently working on a project that will add two hall effect sensors in a position that will have to read shaft speeds in a CVT. I am not really grasping the idea on how to attach interrupts to make these work to display speeds almost simultaneously. The idea of this project is to be able to display(on lcd) the rpm of the carrier (input shaft) and output shaft of the transmission to show how rpms will match and shift gears and the increasing output speed. I have no back ground in coding and i have been trying to teach myself as i go along. However, I am stuck. Can someone help me out with coding or maybe gie me some pointers? (documentation of code is for classmates)

This is my code:

#include<LiquidCrystal.h> // adds LCD to library

byte backlight = 0, rs = 1, rw = 2, enable = 3,
d4 = 4, d5 = 5, d6 = 6, d7 = 7;
// using the byte fucntion, the microprocessor is acknowledging the pin connections from the arduino board to the lcd connections
// note: only 10 out of 16 pins on board are used for display
//see diagram of lcd for pin locations
LiquidCrystal lcd(rs, rw, enable, d4, d5, d6, d7);
volatile byte half_revolutions; // measurement of how many revolutions are counted
unsigned int rpm; //this will be the units
unsigned long timeold; // lenght of time

int HALL1 = 2; // assigning halleffect sensor 1 to pin 2
int HALL2 = 3; // assigning halleffect snesor 2 to pin 3
// you can change which pins your halleffect sensor is connected to just reassign the pin numbers

void setup() {
pinMode(backlight, OUTPUT);
digitalWrite(backlight, HIGH);
lcd.begin (20,4); // telling processor how many rows and columns the LCD has
lcd.setCursor (0,0); //telling the processor where to begin
lcd.print (“Carrier RPM”);
lcd.setCursor (0,1);
lcd.print(DEC);
lcd.setCursor(0,2);
lcd.print (“Output RPM”);
lcd.setCursor (0,3);
lcd.print(DEC);

Serial.begin(9600);
attachInterrupt(0, HALL1, RISING); // connects interrupt to pin 2
// interrup allows you to “multitask” – will switch off one function to show another funtion
// this processor cannot run more than one function at once
attachInterrupt(3, HALL2, RISING); // attaches intterupt to pin 3
half_revolutions=0; // These are all your starting points
rpm=0;
timeold=0;
}

void loop() {

Serial.begin(9600);
attachInterrupt(2, HALL1, RISING); // connects interrupt to pin 2
// interrupt allows you to “multitask” – will switch off one function to show another funtion
// this processor cannot run more than one function at once
attachInterrupt(3, HALL2, RISING); // attaches intterupt to pin 3
half_revolutions=0; // These are all your starting points
rpm=0;
timeold=0;
if (half_revolutions>=20) {
rpm = 30*1000/(millis()-timeold)*half_revolutions;
timeold=millis();
half_revolutions=0;// this section is telling the processor how to convert tO rpm
}
}

A) I would have to know more about your Hall effect sensors, but you probably do not need interrupts for this. Interrupts can be difficult, especially for newbies, and are often unnecessary.

B) You promised to supply a HALL1 and a HALL2 function with

   attachInterrupt(0, HALL1, RISING); // connects interrupt to pin 2
  // interrup allows you to "multitask" -- will switch off one function to show another funtion
  // this processor cannot run more than one function at once
  attachInterrupt(3, HALL2, RISING); // attaches intterupt to pin 3

but then you defined HALL1 and HALL2 as int. What is up with that?

C) You do not state what Arduino you have. Why does one attachInterrupt use a 0 to indicate pin 2, but the other attachInterrupt uses a 3 to indicate pin 3. Seems like a problem, but maybe not.

  1. Please use code tags. If you follow these instructions, your posts will be greatly improved.

To post code and/or error messages:

  1. Use CTRL-T in the Arduino IDE to autoformat your complete code.
  2. Paste the complete autoformatted code between code tags (the </> button)
    so that we can easily see and deal with your code.
  3. Paste the complete error message between code tags (the </> button)
    so that we can easily see and deal with your messages.
  4. If you already posted without code tags, you may add the code tags by
    editing your post. Do not change your existing posts in any other way.
    You may make additional posts as needed.
  5. Please provide links to any libraries that are used
    (look for statements in your code that look like #include ). Many libraries
    are named the same but have different contents.

Before posting again, you should read the three locked topics at the top of the Programming Questions forum, and any links to which these posts point.

If your project involves wiring, please provide a schematic and/or a wiring diagram and/or a clear photograph of the wiring.

Good Luck!

Thanks for the help, I have never programmed anything before, so I have absolutely no clue what I am doing.

Hi, I have a program or sketch that display the turntable rpm in a LCD. I think you can use it for your project. For the sensor also you can use and interrupter infrared that can read a white marker in the shaft. Or Like what you said use a hall effect transistor with a magnet glue to the shaft. Also you can use one like the one use in the cars to read the crankshaft. It is a magnet and coil. I your are interesting I can give you my RPM display sketch.

Hi, I have a program or sketch that display the turntable rpm in a LCD. I think you can use it for your project. For the sensor also you can use and interrupter infrared that can read a white marker in the shaft. Or Like what you said use a hall effect transistor with a magnet glue to the shaft. Also you can use one like the one use in the cars to read the crankshaft. It is a magnet and coil. I your are interesting I can give you my RPM display sketch.