Arduino Giga R1 WiFi Rocker Switch Module
Who turned the heater on, and when was it turned off again? A machine in a tutorial often answers this with an event log: a list of times, one for each start and stop. In this guide, we will learn how to build such a log with the Arduino Giga R1 WiFi and the DIYables ON/OFF Rocker Switch Module. This little board carries the wide, two-sided switch known from power strips, ready to wire with three jumper wires. The Giga writes a time-stamped line for every flip, and its blue LED shows at a glance that the switch is ON. In detail, we will learn:
- How to read the rocker symbols and the "ON (H)" / "OFF (L)" print.
- Why the module gets 3.3V from the Giga and never 5V.
- How to test the wiring with a sketch that shows the rocker position about three times per second.
- How to log each flip once, as a line like "[00:13.402] switched OFF", with a 50 ms debounce that uses millis() and never stops the loop.
- How to light the built-in blue LED of the Giga (LEDB), which turns on with LOW, not with HIGH.

Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
Overview of Rocker Switch Module
Seen from the top, the module shows a black KCD1 rocker with two halves. Under it is a blue square PCB of close to 24 x 24 mm, with four holes near the corners for screws or spacers. From one edge, three header pins bent at a right angle (2.54 mm pitch) stick out sideways. Including those pins, the part takes up about 24 x 29 x 22 mm. DIYables sells it in packs of 5.
Rock the "I" half down: ON. Rock the "O" half down: OFF. The PCB print says the same thing another way, "ON (H)" next to "OFF (L)". Those two letters in brackets give away what the Giga will read: a HIGH level for ON, a LOW level for OFF.
Electricians call this kind of part a maintained (or latching) switch. Inside there is a single contact pair, open or shut, so it is also called SPST. Nothing pushes it back after you flip it. For the program, this means a different question than with a button. With a button, you watch for a press. With this rocker, you check its position and compare it with the one you saw before.

The labels hide on the underside of the board, beside the pins:
- SIG pin: connect to pin 7 of the Giga (another digital pin works too). When the "I" half is down, SIG carries the VCC voltage, which is HIGH. With "O" down, SIG drops to 0V, which is LOW.
- VCC pin: connect it to 3.3V on the Giga. The module works on 3.3V or 5V, yet the Giga allows only 3.3V here (see the note).
- GND pin: connect to GND. Any of the GND pins of the Giga will do.
※ NOTE THAT:
Keep the VCC wire away from the 5V and VIN pins of the Giga. With the rocker ON, the voltage on VCC passes straight through to SIG, and SIG goes into pin 7. The STM32H747 chip on the Giga runs its pins at 3.3V, and 5V on one of its inputs can damage it.
| ON/OFF Rocker Switch Module | |
|---|---|
| Switch | KCD1 rocker, SPST, maintained |
| Marks on the rocker | I = ON, O = OFF |
| Header | SIG, VCC, GND (3 pins, right-angle, 2.54 mm) |
| Supply voltage | 3.3V to 5V |
| SIG output | HIGH when ON, LOW when OFF |
| Resistor on SIG | 10 kOhm pull-down (marked 103) |
| Board | about 24 x 24 mm, 4 mounting holes |
| Size with pins | about 24 x 29 x 22 mm |
A few details shape the code and keep the setup safe:
- When "O" is down, the 10 kOhm pull-down drags SIG to 0V, so the input never floats. That is why the sketches use plain INPUT. Skip the extra resistor, and leave INPUT_PULLUP off, because it would only fight the pull-down.
- The rocker body carries a rating, "6A 250VAC / 10A 125VAC". It describes the bare switch. In this circuit the switch carries about 0.33 mA (3.3V through 10 kOhm). Mains wires and motors have no place on the header pins.
- Right after a flip, the metal contacts chatter open and shut for a few milliseconds. The first sketch reads too slowly to see this. The log sketch polls the pin nonstop, so it needs a 50 ms filter.
The Giga already has tutorials for three related parts. Here is how they compare:
- Arduino Giga R1 WiFi - Switch: the bare two-leg ON/OFF switch, without a PCB. It goes between pin 7 and GND with INPUT_PULLUP turned on, so ON gives LOW, the opposite of this module.
- Arduino Giga R1 WiFi - Button Module: a board with the same three pins, but its button returns to the rest position by itself. That code waits for presses and releases.
- Arduino Giga R1 WiFi - Slide Switch: it also stays where you put it, but it is tiny, has bare legs and carries no labels.
Wiring Diagram
Nothing sits between the module and the Giga: no breadboard and no resistor. Three jumper wires finish the build.

This image is created using Fritzing. Click to enlarge image
| Rocker Switch Module Pin | Arduino Giga R1 WiFi Pin |
|---|---|
| SIG | Pin 7 |
| VCC | 3.3V |
| GND | GND |
Pin 7 is only our pick. If your project already uses it, move the SIG wire to any free digital pin and change ROCKER_SWITCH_PIN to the new number.
How To Program For Rocker Switch Module
Only core Arduino functions are used, so there is nothing to install. Both sketches begin the same way:
- Store the pin number in a constant:
- Set it as an INPUT in setup(); the module's own pull-down keeps the level clean while the rocker is OFF:
- Read it. You get HIGH with the rocker on "I" and LOW with it on "O":
The log sketch needs two more pieces that are special to the Giga:
- The board package names the blue part of the on-board RGB LED LEDB. It works the other way round from most LEDs: LOW lights it, HIGH turns it off.
- Millis() gives the milliseconds since the Giga started. One snprintf() call turns that number into minutes, seconds and milliseconds:
Arduino Giga R1 WiFi Code - Rocker Switch Module Position Check
Before building the log, confirm the wiring. This short sketch looks at pin 7 every 300 ms and writes the rocker position in words, with the raw 0 or 1 in brackets.
Detailed Instructions
Follow these instructions step by step:
- If your Arduino IDE has never worked with the Giga, add its board package first, as shown in Arduino Giga R1 WiFi - Getting Started.
- Run the three wires from the diagram (pin 7, 3.3V, GND).
- Use the USB Type-C cable to connect the Giga to your computer.
- Open the Arduino IDE.
- Pick the board Arduino Giga R1 WiFi and its COM port.
- Copy the code, paste it into an empty sketch window and press Upload.
- Start the Serial Monitor at 9600 baud.
- Begin with the "O" half pressed. After a few lines, rock it to "I", count to two, and rock it back.
Between flips, the screen keeps showing the same text: a latching switch sends the same level until someone moves it. Do you see OFF in both positions? Then pin 7 never gets a voltage. Check the VCC wire first, then the SIG wire.
For a test, a repeating list is fine. A real log should write one line per flip, together with the time it happened. That is the job of the next sketch.
Arduino Giga R1 WiFi Code - Rocker Switch Event Log with Timestamps
Think of a heater on your workbench, a small pump or a test setup, with this rocker as its power switch. Later, you want to know when it was turned on and how long it ran. Now the Giga keeps that record. It prints one line for each real flip:
- "[mm:ss.mmm] switched ON" when the "I" side goes down. The blue LED of the Giga lights up.
- "[mm:ss.mmm] switched OFF" when the "O" side goes down. The blue LED goes dark.
The time is minutes, seconds and milliseconds since the Giga started. There is no hour field: after 59 minutes, the minutes simply keep counting (60, 61, ...).
How the sketch works:
- In setup(), it gives the Serial Monitor at most 3 seconds to connect. The USB port of the Giga reconnects after each upload, and the first line could get lost without this pause. With no computer attached, the sketch goes on by itself.
- The first line records the position at start, and the blue LED is set to match it.
- The debounce uses no delay(). Each time the level on pin 7 changes, the sketch notes the time. A new position counts only when pin 7 has kept it for 50 ms without a single change. So a chattering flip gives one line, not five.
- The time in each line is the moment of the last level change, not the end of the 50 ms wait. So the log shows when the contacts came to rest.
Detailed Instructions
- Keep the same three wires.
- Upload this sketch, and keep the Serial Monitor open at 9600 baud.
- Rock the switch between "I" and "O" several times. Make some ON periods long and one very short. Look at the RGB LED of the Giga while you do it: blue means ON, dark means OFF.
Reading the log is simple subtraction. The first ON period starts at 00:05.917 and ends at 00:13.402, so the switch was ON for 7.485 seconds. The short one in the middle lasted less than one second. The last one runs from 00:21.048 to 01:04.775, which is 43.727 seconds.
Two things to know about this clock:
- Millis() starts from zero after every reset or upload. So the times show how long the Giga has been running, not the time of day. If you need real clock times, a later version could get the time from the internet over the WiFi of the Giga.
- A line appears only when the position changes. If the switch stays ON for an hour, the Serial Monitor stays quiet for an hour. The blue LED is your sign that it is still ON.