Activity › Forums › Questions & Troubleshooting › OneButton.h library
-
OneButton.h library
-
Hi guys good day I just bought a Mini and and just want to ask if OneButton library is compatible with mini.
When im using my nano the onebutton library is working but when i tried loading it at controllino it is not responding
Thank you in advance
#include <OneButton.h>
#include <SPI.h>
#include <Controllino.h>
OneButton OutputSensor(CONTROLLINO_A0, true); //Output Sensor
OneButton ThicknessSensor(CONTROLLINO_A1, true); //Thickness Sensor
OneButton MetalSensor(CONTROLLINO_A2, true); //Metal Sensor
OneButton Reset(CONTROLLINO_A3, true); //Reset
OneButton ErrorSignal(CONTROLLINO_A4, true); //Machine Error signal
byte OS =0; // Output Sensor Counter
byte TS =0; // Thickness Sensor Counter
byte MS =0; // Metal Sensor Counter
byte MSL =0; // Metal Sensor Long Counter
byte Err =0; // Error Counter
void setup() {
Serial.begin(9600);
//BUTTON 1
OutputSensor.attachClick(OutputSingleclick); // link the function to be called on a singleclick event.
//BUTTON 2
ThicknessSensor.attachClick(ThicknessSingleclick); // link the function to be called on a singleclick event.
//BUTTON 3
MetalSensor.attachClick(MetalSingleclick); // link the function to be called on a singleclick event.
MetalSensor.attachLongPressStart(MetalStartLongclick); // link the function to be called on a longpress event.
//BUTTON 4
Reset.attachClick(ResetSingleclick); // link the function to be called on a singleclick event.
//BUTTON 5
ErrorSignal.attachClick(ErrorSingleclick); // link the function to be called on a singleclick event.
pinMode(CONTROLLINO_D0,OUTPUT);
}
void loop() {
OutputSensor.tick(); // check the status of the button
ThicknessSensor.tick(); // check the status of the button
MetalSensor.tick(); // check the status of the button
Reset.tick(); // check the status of the button
ErrorSignal.tick(); // check the status of the button
delay(10); // a short wait between checking the button
}
etc…..
-
-
Hi Peter
Yes I did connect to 24V but still not working
now my issue is I cant upload anything giving me a lot of errors
thanks
-
-
Hi,
please note that the voltage divisor at screw terminals works as an internal pull-down resistor. So you should connect the button between the terminal and the supply voltage. Then it should work, but – you should not activate internal pull-ups in the microcontroller, and it will be inverted (HIGH when pushed, LOW when pulled).
You need to init the buttons in this way
OneButton button(PIN_INPUT, false, false);
Best regards,
Lukas
Log in to reply.