Example Code for UNIHIKER K10&M10 - Digital input/output

Last revision 2026/02/03

Guide to digital I/O with UNIHIKER K10 & M10 using example code.

Hardware Preparation

If Using UNIHIKER K10

  • UNIHIKER K10 * 1
  • Multi Function Expansion Board for UNIHIKER * 1 (Both “For the UNIHIKER K10-Only” and “For the UNIHIKER K10 & M10” are supported, but “For the UNIHIKER K10 & M10” is recommended, as it allows for easier program uploading and debugging even when using only the K10)

If Using UNIHIKER M10

Note: The multi-functional expansion board requires separate power supply when IN use. It can be powered by installing an 18650 battery or from the USB IN of the expansion board, and the PWR power supply switch needs to be turned on.

Extra hardware

Software Preparation

If Using Mind+

  • Mind+ Download
    • Mind+ User Extension: https://github.com/YeezB/ext-UnihikerExpansion

If Using Arduino IDE

Hardware Connection

DFR1216 connection

Use UNIHIKER K10 & Mind+

Use UNIHIKER K10 & Arduino IDE

#include "DFRobot_UnihikerExpansion.h"
DFRobot_UnihikerExpansion_I2C eunihiker(&Wire);
void setup()
{
	Serial.begin(115200);
	while(!eunihiker.begin()){
		Serial.println("NO Deivces !");
		delay(1000);
	} 
	Serial.println("Device connected !");
	eunihiker.setMode(eC0, eReadGpio);
	eunihiker.setMode(eC1, eWriteGpio);
}

void loop()
{
	if(eunihiker.getGpioState(eC0) == 1){
		eunihiker.setGpioState(eC1, eHIGH);
	}
	else{
		eunihiker.setGpioState(eC1, eLOW);
	}
}

UNIHIKER K10 Result

Light on when the button has been pushed down.
Light off when the button has been released.

Use UNIHIKER M10 & Mind+

Use UNIHIKER M10 & Python

from pinpong.board import Board
from dfrobot_unihiker_expansion import UnihikerExpansion, IONum, IOType, GpioState
sys.path.append("/root/mindplus/.lib/thirdExtension/drobot_yeezb-unihikerioexpansion-thirdex")

Board("").begin()

eunihiker = UnihikerExpansion()
eunihiker.set_mode(IONum.C0, IOType.GPIO_IN)
eunihiker.set_mode(IONum.C1, IOType.GPIO_OUT)
while True:
    if (eunihiker.get_gpio_state(IONum.C0) == 1):
        eunihiker.set_gpio_state(IONum.C1, GpioState.HIGH)
    else:
        eunihiker.set_gpio_state(IONum.C1, GpioState.LOW)

UNIHIKER M10 Result

Light on when the button has been pushed down.
Light off when the button has been released.

Was this article helpful?

TOP