Interrupt Problems

Hey guys I'm trying to figure out how to get my arduino to count each drop that passes through an LED emitter detector IR area. I have no idea how to do that and I'm a huge noob with interrupts. Any ideas? Here's what I have so far and this part is only for determining the pH of the solution that I stick a probe into. Again major noob so sorry if this is a dumb question.

// Ph Adapter 1130 test

// variable to hold the analog input value int analogValue = 0;

void setup() { // begin the serial communication Serial.begin(9600);

float temperature = 25.0; // or some other degrees C value if you know it or measured it

int digitalValue = analogRead(0); float voltageValue = digitalValue * 0.0049; // from Arduino reference float pH = 7.0 - (2.5 - voltageValue) / (0.257179 + 0.000941468 * temperature); // from p. 8 of Phidget 1130 manual } void loop() { // read the analog input on pin 0 analogValue = analogRead(0);

float temperature = 25.0; // or some other degrees C value if you know it or measured it

int digitalValue = analogRead(0); float voltageValue = digitalValue * 0.0049; // from Arduino reference float pH = 7.0 - (2.5 - voltageValue) / (0.257179 + 0.000941468 * temperature); // from p. 8 of Phidget 1130 manual

// print as an ASCII-encoded decimal Serial.print(pH, DEC);

// print a terminal newline character so the AVR Voltmeter // will know that it has received the full string Serial.print('\n');

// delay 1 second before the next reading: delay(1000); }

It may be that you don't need interrupts, but until you get rid of the "delay" in your code, your existing sketch will not be responsive enough.

Please post code between [code] [/code] tags

I'm trying to figure out how to get my arduino to count each drop that passes through an LED emitter detector IR area.

How big is the drop? How big is the detector area? In other words, how long is the detector HIGH when a drop is present?

Interrupts may not be required.

  // delay 1 second before the next reading:
  delay(1000);

This, of course, would have to go.

The drop is a regular sized drop like from an eye dropper and the IR LED field is about 2 inches across. I'm new to this whole thing so I have no idea about how to get this to detect and count drops. Here's the code again without the delay part

// Ph Adapter 1130 test

// variable to hold the analog input value int analogValue = 0;

void setup() { // begin the serial communication Serial.begin(9600);

float temperature = 25.0; // or some other degrees C value if you know it or measured it

int digitalValue = analogRead(0); float voltageValue = digitalValue * 0.0049; // from Arduino reference float pH = 7.0 - (2.5 - voltageValue) / (0.257179 + 0.000941468 * temperature); // from p. 8 of Phidget 1130 manual } void loop() { // read the analog input on pin 0 analogValue = analogRead(0);

float temperature = 25.0; // or some other degrees C value if you know it or measured it

int digitalValue = analogRead(0); float voltageValue = digitalValue * 0.0049; // from Arduino reference float pH = 7.0 - (2.5 - voltageValue) / (0.257179 + 0.000941468 * temperature); // from p. 8 of Phidget 1130 manual

// print as an ASCII-encoded decimal Serial.print(pH, DEC);

// print a terminal newline character so the AVR Voltmeter // will know that it has received the full string Serial.print('\n');

}

Now you’re going to spend a long time waiting for the serial port’s transmit buffer to empty.

When we said get rid of it, we meant “replace it with something that will perform the function, but waste fewer processor cycles”.
See the blink without delay tutorial for ideas on how to achieve this.

Please post code between tags.

What does reading drops passing a IR sensor have to do with measuring pH? Ditch all that crap dealing with reading that sensor, and write a new sketch that just counts drops. When you can accurately count drops, however that needs to be done, then you can combine that with reading a pH sensor.