mathertel / OneButton

An Arduino library for using a single button for multiple purpose input.
http://www.mathertel.de/Arduino/OneButtonLibrary.aspx
Other
920 stars 230 forks source link

HOMING #133

Closed arjunrayudu closed 7 months ago

arjunrayudu commented 8 months ago

include

include "OneButton.h"

// Setup a new OneButton on pin A1.
OneButton button1(A1, true);

// setup code here, to run once: void setup() { // Setup the Serial port. see http://arduino.cc/en/Serial/IfSerial Serial.begin(115200); while (!Serial) { ; // wait for serial port to connect. Needed for Leonardo only } Serial.println("$X");

// link the button 1 functions. button1.attachClick(click1);

} // setup

// main code here, to run repeatedly: void loop() { // keep watching the push buttons: button1.tick();

// You can implement other code in here or just wait a while // delay(10); } // loop

// ----- button 1 callback functions

// This function will be called when the button1 was pressed 1 time (and no 2. button press followed).

void sendWait(char * s) { bool found = false; while (Serial.read() > 0); // read any previous junk

Serial.println(s);

while (!found) { while(Serial.available() < 2); if (Serial.read() == 'o' && Serial.peek() == 'k') found = true; } }

void click1()

{

sendWait("G0 Y0 X0 "); sendWait("G0 Y-10 "); sendWait("G0 x-30 "); sendWait("G0 x30 "); sendWait("G0 x0 "); sendWait("G0 y-15 "); sendWait("G0 x-50 "); sendWait("G0 x50 "); sendWait("G0 y-15 "); sendWait("G0 x50 "); sendWait("G0 x0 "); sendWait("G0 xy0 ");

} // click1

// This function will be called when the button1 was pressed 2 times in a short timeframe. void doubleclick1() { Serial.println("M5"); } // doubleclick1

// This function will be called once, when the button1 is pressed for a long time. void longPressStart1() { Serial.println("Button 1 longPress start"); } // longPressStart1

// This function will be called often, while the button1 is pressed for a long time. void longPress1() { Serial.println("Button 1 longPress..."); } // longPress1

// This function will be called once, when the button1 is released after beeing pressed for a long time. void longPressStop1() { Serial.println("Button 1 longPress stop"); } // longPressStop1

Please can someone help me I like to experiment with arduino I made a small code to work with Onebutton GRBL link but pc UGS works fine but Onebutton doesn't work thank you best regords