Key.begin()

From Microduino Wiki
Jump to: navigation, search

Key.begin(mode)


Description

Initial a switch, set the input mode which is INPUT by default, and INPUT_PULLUP is optional.

Parameter

Mode: INPUT or INPUT_PULLUP, the default is INPUT.

Return value

None

Sample

  • Set an analog switch
#include <Microduino_Key.h>

AnalogKey keyAnalog(A0);

void setup() {
  Serial.begin(9600);
  keyAnalog.begin(INPUT);
}

void loop() {

}


  • Set an digital switch
#include <Microduino_Key.h>

DigitalKey keyDigital(A0);

void setup() {
  Serial.begin(9600);
  keyDigital.begin(INPUT_PULLUP);
}

void loop() {

}


  • Set an virtual switch
#include <Microduino_Key.h>

VirtualKey keyVirtual;

void setup() {
  Serial.begin(9600);
  keyVirtual.begin();
}

void loop() {

}

Others