myCobot icon indicating copy to clipboard operation
myCobot copied to clipboard

How to read button on Atom

Open peteh opened this issue 4 years ago • 6 comments

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?

peteh avatar May 30 '21 07:05 peteh

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

wxy6655 avatar Jun 30 '21 02:06 wxy6655

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

peteh avatar Jul 02 '21 08:07 peteh

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.

wxy6655 avatar Jul 05 '21 02:07 wxy6655

unsubscribe

------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2021年7月5日(星期一) 上午10:49 收件人: @.>; 抄送: @.***>; 主题: Re: [elephantrobotics/myCobot] How to read button on Atom (#18)

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.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

zhouliqingyannuo avatar Jul 05 '21 02:07 zhouliqingyannuo

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?

peteh avatar Jul 05 '21 03:07 peteh

#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);
}

wxy6655 avatar Jul 06 '21 08:07 wxy6655