Control box for my planter monitor test stand




This is the circuit for my planter test stand used to test seed meters for uniform seed placement. The blue board on the left is an Arduino Uno Rev.3. On the right is an Arduino Proto Shield that mounts on top of the Uno with "headers". I've added the wiring illustrated. Where I have drawn the row sensor wires, I actually have a piece of cable cut off an old row sensor that has a male weather-pack connector where the row sensor connects. The Arduino is supplying +5v power to the row sensor through the red and black wires. For interfacing to a PC via USB cable, take off the Bluetooth module and wiring but keep the 10K resistor that holds the seed sensor signal wire high (to +5V). The Arduino needs to be powered from its round power connector or through the USB cable to a PC.

The Arduino code:
/* Each time the a row's input pin goes from LOW to HIGH (e.g. because of a seed
passing the sensor), the output pin is toggled from LOW to HIGH. There's
a minimum delay between toggles to debounce the circuit (i.e. to ignore noise).

created 27 April 2013 by modifying the Example / Digital / Debounce
updated 6 August 2017
by James K. Poyzer

*/
long millisAtGPS = 0;
String rowinfo = "";
long debounceDelay = 3; // the debounce time; increase if the output flickers
int systemResetDelay = 1000;
int reading = 0;
int takeAction = 0;
int sensorState = 0;
int newSensorState = 0;
int lastSensorState = 0;
long lastDebounceTime = 0;
long millisAtLastSeed = 0;
int millisSinceLastSeed = 0;
long seedGap = 0;
//*******************************************************************
void setup() {
Serial.begin(9600); // Initialize serial communications on serial port
Serial.println("Uno_TestStand_8_5_17");

pinMode(2, INPUT_PULLUP);
lastDebounceTime = 0;
millisAtLastSeed = millis();
digitalWrite(2, HIGH);/
delay (systemResetDelay);
} //void setup

void loop() {
if ((millis() - lastDebounceTime) > debounceDelay) {
// don't take a reading everytime, wait for
// the delay time before checking to see if something
// changed
takeAction = 1;
} // delayed long enough for reading to be stable

if (takeAction == 1) {
reading = digitalRead(2); // read will be high or low (1 or 0)
if (reading != lastSensorState) { // not equal
newSensorState = reading;
if (newSensorState == LOW) {
// okay to write record
seedGap = (millis() - millisAtLastSeed);
rowinfo = ("R01");
if (seedGap < 10) {
rowinfo = rowinfo + "0";
}
if (seedGap < 100) {
rowinfo = rowinfo + "0";
}
if (seedGap > 999) {
seedGap = 999;
}
rowinfo = rowinfo + String(seedGap) + "X";
Serial.println(rowinfo); // output looks like "R01057X" - row 1 with 57 milliseconds between seeds
takeAction = 0; // delay next time it comes to this row
millisAtLastSeed = millis(); //to be used when next seed comes
lastDebounceTime = millis(); // for delaying next look
} // sensorState = LOW
lastSensorState = reading;
} // reading != old one
} // end where takeAction was 1

} // end of void loop