![OPEN-SMART Rich UNO R3 Скачать руководство пользователя страница 31](http://html1.mh-extra.com/html/open-smart/rich-uno-r3/rich-uno-r3_user-manual_1639721031.webp)
OPEN-SMART Email:
- 31 -
8.3 Learn the functions
1)
You can find that at the beginning of all lessons code is
#include <Wire.h>
#include <SoftwareSerial.h>
Because the RichUNO library files use Wire.h and SoftwareSerial.h which is not in the RichUNO
directory, if the example code wants to use RichUNO library, it should add those two line.
2)
Other header files
In lesson 4 we use 4-digit display and touch sensor, so it should include their header files to
control display more easily.
So you should add:
#include "RichUNOTouchSensor.h"
#include "RichUNOTM1637.h"
3) Define class object
We have defined the display class and touch sensor class in the RichUNO library, and at any time
you should define a object before you use it, and some object has parameter.
For example:
TouchSensor touch(3,4,5,6);//define a touch sensor object, and display connect to D3 / D4 / D5 /
D6 of Rich UNO R3 board
4) Two necessary functions
Each example code should inclue the two necessary functions:
void setup(){ }
void loop(){}
Usually we write initialization code in setup function, and then write the code what you want the
board to do in loop function which runs cyclically.
5) Functions
* touch.get(); / / return is the touch area corresponding Arduino pin number, if not then return -1
If you touch TCH1, it will return 3. TCH2 is 4, TCH3 is 5, and TCH4 is 6.
You may try to write this function to get 1,2,3,4 for TCHx.
int get()
{
int touchNum;
int _pin;
_pin = touch.get();
switch(_pin)
{
case TOUCH_OUT1: touchNum = 1;break;
case TOUCH_OUT2: touchNum = 2;break;
case TOUCH_OUT3: touchNum = 3;break;
case TOUCH_OUT4: touchNum = 4;break;