Hi all.
Starting a few weeks ago I felt spry and decided that I, having minimal experience with Arduinos, wanted to design and fabricate a completely automated can crusher controled by an Elegoo Arduino Uno. To my surprise, it has been fairly smooth sailing! Resources such as this forum and Tinkercad have got me much further, much faster than I thought I would have. Now the project is nearly complete save one aspect: automated triggering.
I purchased a 4.5-30VDC Taiss NJK-5002C NPN NO Hall Sensor to trigger the crushing sequence when a can is present. For the life of me I cannot seem to get this sensor to cooperate. I have set up a very bare bones circuit in an attempt to even get a response out of the sensor and so far nothing. Below is my code and attached is my circuit and sensor info:
#define sensorPin 2 // Defining the sensor trigger
const int wait = 1000; // Wait 1 second after activation
void setup() {
pinMode(sensorPin, INPUT_PULLUP); // Defining sensor input
pinMode(13, OUTPUT); //Built in LED as Output
Serial.begin(9600); // Initialize serial monitor
}
void loop() {
int sensed = digitalRead(sensorPin); //Read pin 2 and creat 'on/off' binary
if(sensed == HIGH){
Serial.println("Sensed");
digitalWrite(13, HIGH); // Turn on LED if sensed
delay(wait); //Keep on for the value defined above
}else{
digitalWrite(13, LOW); // LED off if not sensed
Serial.println("=====");
}
delay(300); // Delay for reads
}
I have seen setups on YouTube nearly identical to this function, but am at a loss. I have a few PC817 optocouplers on the way to try the sensor with 12 volt and a relay.
Any help would be greatly appreciated. Thanks!

