// Pin Definitions
const int sensorPin = 32; // Pin for the inductive sensor (simulated as a button)
const int motorPin = 9; // Pin for the seed dispenser (motor or servo)
void setup() {
pinMode(sensorPin, INPUT); // Set sensor pin as input
pinMode(motorPin, OUTPUT); // Set motor pin as output
Serial.begin(9600); // Start serial communication
}
void loop() {
int sensorState = digitalRead(sensorPin); // Read sensor state
if (sensorState == HIGH) {
// If sensor detects metal (button pressed), activate motor to dispense seeds
digitalWrite(motorPin, HIGH);
Serial.println("Seed Dispensed");
} else {
// Otherwise, keep motor off
digitalWrite(motorPin, LOW);
}
delay(100); // Small delay to avoid bouncing
}