Git Product home page Git Product logo

yk04_module's Introduction

YK04 Controller Library

For Arduino boards.

The library implements a set of methods for working with a remote control sensors based on the YK04 driver.

The transmitter operates at a frequency of 315 MHz. It has four buttons, and therefore can control four loads. The board with a battery (23A, 12V) is placed in a convenient plastic case-keychain. It has a telescopic antenna, which will increase the range of signal transmission. There is protection against accidental pressing the buttons. It is realized with the help of a sliding cover.

Installation

  1. Download the Latest release from GitHub.
  2. Unzip and modify the Folder name to "YK04_Controller" (Remove the '-version')
  3. Paste the modified folder on your Library folder (On your libraries folder inside Sketchbooks or Arduino software).
  4. Restart the Arduino IDE.

Circuit Diagram

Circuit Diagram

Methods

	/**
		Digital ports pins:
			@param A_pin - A button (D0).
			@param B_pin - B button (D1).
			@param C_pin - C button (D2).
			@param D_pin - D button (D3).
	*/
	YK04_Module* yk04 = new YK04_Module(A_PIN, B_PIN, C_PIN, D_PIN);

	/**
		If you want to invert a sensor signal:
		INVERT_SIGNAL:
			true - invert a signal;
			false - not invert a signal.
	*/
	YK04_Module* yk04 = new YK04_Module(A_PIN, B_PIN, C_PIN, D_PIN, INVERT_SIGNAL);

	/**
		Single reading of the remote control.
		If the remote control is clamped,
		value of the next pressing - NOT.
		Return value of pressing the remote control:
			Button::A - A button is pressed;
			Button::B - B button is pressed;
			Button::C - C button is pressed;
			Button::D - D button is pressed;
			Button::NOT - not pressed.
	*/
	yk04->singleRead();

	/**
		Multiple reading of the remote control.
		If the remote control is clamped,
		returns a pressed button value.
		Return value of pressing the remote control:
			Button::A - A button is pressed;
			Button::B - B button is pressed;
			Button::C - C button is pressed;
			Button::D - D button is pressed;
			Button::NOT - not pressed.
	*/
	yk04->multipleRead();

	/**
		Checks if the A button is pressed.
		Return true - button is pressed,
		false - button is not pressed.
	*/
	yk04->isA();

	/**
		Checks if the B button is pressed.
		Return true - button is pressed,
		false - button is not pressed.
	*/
	yk04->isB();

	/**
		Checks if the C button is pressed.
		Return true - button is pressed,
		false - button is not pressed.
	*/
	yk04->isC();

	/**
		Checks if the D button is pressed.
		Return true - button is pressed,
		false - button is not pressed.
	*/
	yk04->isD();

See examples...

Created by Yurii Salimov.

yk04_module's People

Contributors

suoapvs avatar

Stargazers

ecoteh.com.ua avatar  avatar  avatar  avatar Pneumo.kiev.ua avatar

Watchers

James Cloos avatar  avatar

yk04_module's Issues

Not working in my case

Maybe it will help somebody. This library not work for my YK04 from aliexpress.
For arduino the following code only start to work.

#define A_PIN 7 //D2
#define B_PIN 6 //D0
#define C_PIN 5 //D3
#define D_PIN 4 //D1

void setup() {
Serial.begin(9600);
pinMode(A_PIN, INPUT_PULLUP);
pinMode(B_PIN, INPUT_PULLUP);
pinMode(C_PIN, INPUT_PULLUP);
pinMode(D_PIN, INPUT_PULLUP);
}

void loop() {
int ValueA = not digitalRead(A_PIN);
int ValueB = not digitalRead(B_PIN);
int ValueC = not digitalRead(C_PIN);
int ValueD = not digitalRead(D_PIN);

// Serial.print(ValueA);Serial.print(" - ");Serial.print(ValueB);Serial.print(" - ");
// Serial.print(ValueC);Serial.print(" - ");Serial.print(ValueD);Serial.println(" - ");

if (ValueB == HIGH && ValueC == HIGH && ValueD == HIGH){
Serial.println("Press A");
}
if (ValueA == HIGH && ValueC == HIGH && ValueD == HIGH){
Serial.println("Press B");
}
if (ValueA == HIGH && ValueB == HIGH && ValueD == HIGH){
Serial.println("Press С");
}
if (ValueA == HIGH && ValueB == HIGH && ValueC == HIGH){
Serial.println("Press D");
}
delay(100);
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.