Seeed Grove User manual

3/24/2019 Grove - 5-Way Switch - Seeed Wiki
http://wiki.seeedstudio.com/Grove-5-Way_Switch/ 1/12
Grove - 5-Way Switch
The Grove - 5-Way Switch can be used to detect the switch position and event like
single click/double click/long press, etc. It can detect left/right/up/down/center 5
directions. The 5-way switch will be a great option for multifunction control.
With only one small switch to meet all your needs for switch control!

3/24/2019 Grove - 5-Way Switch - Seeed Wiki
http://wiki.seeedstudio.com/Grove-5-Way_Switch/ 2/12
[https://www.seeedstudio.com/Grove-5-
Way-Switch-p-3136.html]
Features
5 way individual switch
Good heat resistance
Long operating Life
Grove compatible
Specication
Item Value
Operating voltage 3.3V / 5V
Interface I C
Default I C Address 0x03
Applications
Game control
Multifunction control
Hardware Overview
Pin Map
2
2

3/24/2019 Grove - 5-Way Switch - Seeed Wiki
http://wiki.seeedstudio.com/Grove-5-Way_Switch/ 3/12
Platforms Supported

3/24/2019 Grove - 5-Way Switch - Seeed Wiki
http://wiki.seeedstudio.com/Grove-5-Way_Switch/ 4/12
Arduino Raspberry Pi BeagleBone Wio LinkIt ONE
Getting Started
Play With Arduino
Hardware
Materials required
Seeeduino V4.2 Base Shield Grove - 5-Way S
Get One Now
[http://www.seeedstudio.com/Seeeduino-
V4.2-p-2517.html]
Get One Now
[https://www.seeedstudio.com/Base-
Shield-V2-p-1378.html]
Get One Now
[https://www.s
5-Way-Switch-p
Caution
The platforms mentioned above as supported is/are an indication of the module's software or
theoritical compatibility. We only provide software library or code examples for Arduino
platform in most cases. It is not possible to provide software library / demo code for all
possible MCU platforms. Hence, users have to write their own software library.

3/24/2019 Grove - 5-Way Switch - Seeed Wiki
http://wiki.seeedstudio.com/Grove-5-Way_Switch/ 5/12
Step 1. Connect the Grove - 5-Way Switch to the I C port of the Base Shield.
Step 2. Plug Grove - Base Shield into Seeeduino.
Step 3. Connect Seeeduino to PC via a USB cable.
Note
1 Please plug the USB cable gently, otherwise you may damage the port. Please use the USB
cable with 4 wires inside, the 2 wires cable can't transfer data. If you are not sure about the wire
you have, you can click here [https://www.seeedstudio.com/Micro-USB-Cable-48cm-p-
1475.html] to buy
2 Each Grove module comes with a Grove cable when you buy. In case you lose the Grove
cable, you can click here [https://www.seeedstudio.com/Grove-Universal-4-Pin-Buckled-20cm-
Cable-%285-PCs-pack%29-p-936.html] to buy.
2
Note
If we don't have Grove Base Shield, We also can directly connect this module to Seeeduino as
below.

3/24/2019 Grove - 5-Way Switch - Seeed Wiki
http://wiki.seeedstudio.com/Grove-5-Way_Switch/ 6/12
Seeeduino Grove - 5-Way Switch
5V Red
GND Black
SDA White
SCL Yellow
Software
Step 1. Download the Grove Multi Switch [https://github.com/Seeed-
Studio/Grove_Multi_Switch] Library from Github.
Step 2. Refer to How to install library
[http://wiki.seeedstudio.com/How_to_install_Arduino_Library] to install library
for Arduino.
Step 3. Restart the Arduino IDE. Open example via the path: File → Examples →
Grove Multi Switch Library → Grove_Switch_Events.
Attention
If this is the rst time you work with Arduino, we strongly recommend you to see Getting
Started with Arduino [http://wiki.seeedstudio.com/Getting_Started_with_Arduino/] before the
start.

3/24/2019 Grove - 5-Way Switch - Seeed Wiki
http://wiki.seeedstudio.com/Grove-5-Way_Switch/ 7/12
Or, you can just click the icon in upper right corner of the code block to copy the
following code into a new sketch in the Arduino IDE.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "Grove_Multi_Switch.h"
GroveMultiSwitch mswitch[1];
const char* grove_5way_tactile_keys[] = {
"KEY A",
"KEY B",
"KEY C",
"KEY D",
"KEY E",
};
const char* grove_6pos_dip_switch_keys[] = {
"POS 1",
"POS 2",
"POS 3",
"POS 4",
"POS 5",
"POS 6",
};
const char** key_names;
int deviceDetect(void) {
if (!mswitch->begin()) {
Serial.println("***** Device probe failed *****");
return -1;

3/24/2019 Grove - 5-Way Switch - Seeed Wiki
http://wiki.seeedstudio.com/Grove-5-Way_Switch/ 8/12
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
}
Serial.println("***** Device probe OK *****");
if (PID_VAL(mswitch->getDevID()) == PID_5_WAY_TACTILE_SWITCH)
Serial.println("Grove 5-Way Tactile Switch Inserted!");
key_names = grove_5way_tactile_keys;
} else if (PID_VAL(mswitch->getDevID()) == PID_6_POS_DIP_SWITC
Serial.println("Grove 6-Position DIP Switch Inserted!");
key_names = grove_6pos_dip_switch_keys;
}
// enable event detection
mswitch->setEventMode(true);
// report device model
Serial.print("A ");
Serial.print(mswitch->getSwitchCount());
Serial.print(" Button/Switch Device ");
Serial.println(mswitch->getDevVer());
return 0;
}
void setup()
{
Serial.begin(115200);
Serial.println("Grove Multi Switch");
// Initial device probe
if (deviceDetect() < 0) {
Serial.println("Insert Grove 5-Way Tactile");
Serial.println("or Grove 6-Position DIP Switch");
for (;;);
}
return;
}
void loop()
{
GroveMultiSwitch::ButtonEvent_t* evt;
delay(1);
evt = mswitch->getEvent();
if (!evt) {

3/24/2019 Grove - 5-Way Switch - Seeed Wiki
http://wiki.seeedstudio.com/Grove-5-Way_Switch/ 9/12
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// dynamic device probe
deviceDetect();
delay(1000);
return;
}
if (!(evt->event & GroveMultiSwitch::BTN_EV_HAS_EVENT)) {
#if 0
Serial.print("No event, errno = ");
Serial.println(mswitch->errno);
#endif
return;
}
for (int i = 0; i < mswitch->getSwitchCount(); i++) {
Serial.print(key_names[i]);
Serial.print(": RAW - ");
Serial.print((evt->button[i] & GroveMultiSwitch::BTN_EV_RA
"HIGH ": "LOW ");
if (PID_VAL(mswitch->getDevID()) == PID_5_WAY_TACTILE_SWIT
Serial.print((evt->button[i] & GroveMultiSwitch::BTN_E
"RELEASED ": "PRESSED ");
} else if (PID_VAL(mswitch->getDevID()) == PID_6_POS_DIP_S
Serial.print((evt->button[i] & GroveMultiSwitch::BTN_E
"OFF ": "ON ");
}
Serial.println("");
}
for (int i = 0; i < mswitch->getSwitchCount(); i++) {
if (evt->button[i] & ~GroveMultiSwitch::BTN_EV_RAW_STATUS)
Serial.println("");
Serial.print(key_names[i]);
Serial.print(": EVENT - ");
}
if (evt->button[i] & GroveMultiSwitch::BTN_EV_SINGLE_CLICK
Serial.print("SINGLE-CLICK ");
}
if (evt->button[i] & GroveMultiSwitch::BTN_EV_DOUBLE_CLICK
Serial.print("DOUBLE-CLICK ");
}
if (evt->button[i] & GroveMultiSwitch::BTN_EV_LONG_PRESS)
Serial.print("LONG-PRESS ");
}
if (evt->button[i] & GroveMultiSwitch::BTN_EV_LEVEL_CHANGE

3/24/2019 Grove - 5-Way Switch - Seeed Wiki
http://wiki.seeedstudio.com/Grove-5-Way_Switch/ 10/12
Step 4. Upload the demo. If you do not know how to upload the code, please
check How to upload code [http://wiki.seeedstudio.com/Upload_Code/].
Step 5. Open the Serial Monitor of Arduino IDE by click Tool-> Serial Monitor.
Or tap the Ctrl +Shift +M key at the same time. Set the baud rate to 115200.
116
117
118
119
120
Serial.print("LEVEL-CHANGED ");
}
}
Serial.println("");
}
Success
If every thing goes well, you will get the result. When you press the KEY E, it will trigger KEY E:
RAW - LOW PRESSED
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Grove Multi Switch
***** Device probe Device BN-5E-0.1
Grove Multi Switch
***** Device probe OK *****
Grove 5-Way Tactile Switch Inserted!
A 5 Button/Switch Device BN-5E-0.1
KEY A: RAW - HIGH RELEASED
KEY B: RAW - HIGH RELEASED
KEY C: RAW - HIGH RELEASED
KEY D: RAW - HIGH RELEASED
KEY E: RAW - LOW PRESSED
KEY E: EVENT - LEVEL-CHANGED
KEY A: RAW - HIGH RELEASED
KEY B: RAW - HIGH RELEASED
KEY C: RAW - HIGH RELEASED
KEY D: RAW - HIGH RELEASED
KEY E: RAW - HIGH RELEASED
KEY E: EVENT - SINGLE-CLICK LEVEL-CHANGED
KEY A: RAW - LOW PRESSED
KEY B: RAW - HIGH RELEASED
KEY C: RAW - HIGH RELEASED
KEY D: RAW - HIGH RELEASED
KEY E: RAW - HIGH RELEASED

3/24/2019 Grove - 5-Way Switch - Seeed Wiki
http://wiki.seeedstudio.com/Grove-5-Way_Switch/ 11/12
Resources
[Zip] Grove - 5-Way Switch eagle les
[https://github.com/SeeedDocument/Grove-5-
Way_Switch/raw/master/res/Grove-5-Way_Switch.zip]
[Zip] Grove Multi Switch Library [https://github.com/Seeed-
Studio/Grove_Multi_Switch/archive/master.zip]
Project
This is the introduction Video of this product, simple demos, you can have a try.
27
28
29
30
31
32
KEY A: EVENT - LEVEL-CHANGED
KEY A: RAW - HIGH RELEASED
KEY B: RAW - HIGH RELEASED
KEY C: RAW - HIGH RELEASED
KEY D: RAW - HIGH RELEASED
KEY E: RAW - HIGH RELEASED
Other manuals for Grove
14
Table of contents
Other Seeed Switch manuals
Popular Switch manuals by other brands

SMC Networks
SMC Networks TigerSwitch SMC6128PL2 Management guide

Tekvox
Tekvox TEK 1201-N user manual

Electroswitch
Electroswitch 31201B user manual

Redback
Redback A 4460 operating manual

Cisco
Cisco Catalyst 2820 Frequently asked questions

THOMSON
THOMSON Grass Valley TRITON TTN-BTS-0808/140 installation manual

Banner
Banner PICO-GUARD SFI-D1EDPXT6 instruction manual

D-Link
D-Link 1016R - DES Switch user guide

Synergy Global Technology
Synergy Global Technology LCDK1023 user manual

Lantronix
Lantronix SM TAT4X Series install guide

Motorola
Motorola WS5100 Series Migration giude

StarTech.com
StarTech.com SV231DVGAU2A quick start guide