Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to read button on Atom #18

Open
peteh opened this issue May 30, 2021 · 6 comments
Open

How to read button on Atom #18

peteh opened this issue May 30, 2021 · 6 comments

Comments

@peteh
Copy link

peteh commented May 30, 2021

Hi,

I could not find any documentation how to read the button on the Atom Lite.

It's supposed to be connected to G39 on the Atom, however the following code does not work when flashed to the basic:
int value = m_mycobotBasic.getDigitalInput(39);

it always returns -1.

How can I get button Events?

@wxy6655
Copy link
Collaborator

wxy6655 commented Jun 30, 2021

Hello, the function of this case is not open yet, only IO pins are open at present

@peteh
Copy link
Author

peteh commented Jul 2, 2021

Is there a plan when it will be available? Currently the button is pretty useless.

@wxy6655
Copy link
Collaborator

wxy6655 commented Jul 5, 2021

Hello, I have confirmed that the button function is available, provided that you set it to the input state, I see that you seem to use it directly, maybe you can set it to the input state first, you can use set_pin_mode() to set it , And then use the read function.

@zhouliqingyannuo
Copy link

zhouliqingyannuo commented Jul 5, 2021 via email

@peteh
Copy link
Author

peteh commented Jul 5, 2021

Hello, I have confirmed that the button function is available, provided that you set it to the input state, I see that you seem to use it directly, maybe you can set it to the input state first, you can use set_pin_mode() to set it , And then use the read function.

I tried to do that, however without success (tested with Atom 2.8).

Do you have some sample code that I could use? Do I have to constantly poll the state of the input or is it possible to react on events?

@wxy6655
Copy link
Collaborator

wxy6655 commented Jul 6, 2021

#include <MycobotBasic.h>
#include <ParameterList.h>

MycobotBasic myCobot;


void setup(){
  myCobot.setup();                                      
  myCobot.powerOn();                                
  pinMode(21,OUTPUT);
  pinMode(22,OUTPUT);
  myCobot.setPinMode(39,INPUT);
}

void loop(){
  Serial.println(myCobot.getDigitalInput(39));
  delay(200);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants