Example Code for UNIHIKER K10 - Digital input/output

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

Hardware Preparation

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.

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.

Was this article helpful?

TOP