Data Sheet
4/27/2018 OpenCR1.0
http://emanual.robotis.com/docs/en/parts/controller/opencr10/ 31/50
7. 2. Button
It is a built-in BUTTON test on the OpenCR board.
7. 2. 1. Code
There are Push switches SW1 ~ 2 and Dip switches 1 ~ 2 in OpenCR. The pin number is
defined as below, so you can see the status of the current button when you input the data
of that pin.
It is a code that outputs the button input status in serial.
7. 2. 2. Result
OpenCR Arduino Test - BUTTON
7. 3. Buzzer
It is a BUZZER related test built in the OpenCR board and uses the Tone function of Arduino.
7. 3. 1. Code
#define BDPIN_DIP_SW_1 26
#define BDPIN_DIP_SW_2 27
#define BDPIN_PUSH_SW_1 34
#define BDPIN_PUSH_SW_2 35
void setup(){
Serial.begin(115200);
pinMode(BDPIN_DIP_SW_1, INPUT);
pinMode(BDPIN_DIP_SW_2, INPUT);
pinMode(BDPIN_PUSH_SW_1, INPUT);
pinMode(BDPIN_PUSH_SW_2, INPUT);
}
void loop(){
int dip_state;
int push_state;
dip_state = digitalRead(BDPIN_DIP_SW_1)<<0;
dip_state |= digitalRead(BDPIN_DIP_SW_2)<<1;
push_state = digitalRead(BDPIN_PUSH_SW_1)<<0;
push_state |= digitalRead(BDPIN_PUSH_SW_2)<<1;
Serial.print("dip_state = ");
Serial.print(dip_state, BIN);
Serial.print("\tpush_state = ");
Serial.println(push_state, BIN);
delay(100);
}
OpenCR1.0
Back to Top ▲