Hi,
I need to connect 2 Endstops to the pins of ESP8266, but I don't know how.
The goal is when an object touches Endstop, the stepper motor will stop working.
I'll appreciate any help.
Thanks
Hi,
I need to connect 2 Endstops to the pins of ESP8266, but I don't know how.
The goal is when an object touches Endstop, the stepper motor will stop working.
I'll appreciate any help.
Thanks
Connect the switches between input pin and ground.
Configure the pin as INPUT_PULLUP.
You can use wires to connect button, switches or what ever to the ESP.
As my red Endstop has 3 wires:
Red: +5V to Normally Closed contact and LED
Black: Ground to Normally Open contact.
Green: Signal from Common contact and +5V pull-up.
Should i connect them:
Black to GND
Green to 3V
Red to D4
So the following testing code would work:
const int ENDSTOP_PIN = 1; // GPIO2
void setup() {
pinMode(ENDSTOP_PIN, INPUT_PULLUP); // Set GPIO2 as input with a pullup resistor
attachInterrupt(digitalPinToInterrupt(ENDSTOP_PIN), endstopTriggered, FALLING); // Attach an interrupt to the endstop pin
Serial.begin(115200); // Start serial communication at 115200 baud rate
}
void loop() {
// Do nothing in the loop, we're just waiting for the interrupt to trigger
}
void endstopTriggered() {
Serial.println("Endstop triggered!"); // Print a message to the serial monitor
}
You need only the NO or the NC, but not both.
Read the datasheet how to connect.
p.s.
Post a link.
Post a link of the Endstop switch.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.