![OPEN-SMART Rich UNO R3 Скачать руководство пользователя страница 38](http://html1.mh-extra.com/html/open-smart/rich-uno-r3/rich-uno-r3_user-manual_1639721038.webp)
OPEN-SMART Email:
- 38 -
10.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 6 we use 4-digit display, touch sensor and timer one, so it should include their header
files to control display more easily.
So you should add:
#include <TimerOne.h>
#include "RichUNOTM1637.h"
#include "RichUNOTouchSensor.h"
3) Define class object
We have defined the display class in the RichUNO library, and at any time you should define a
object before you use it, and some object has parameter. Timer1 is an object defined in
<TimerOne.h>, you can use it directly.
For example:
TM1637 disp(10,11);
//define a TM1637 object, and display connect to D10 / D11 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
* Timer1.initialize(unsigned long microseconds); // set the timed length, the unit is microseconds
* Timer1.attachInterrupt(TimingISR); // set interrupt routine function name, is the timing interrupt
entry, when the time is up, it will call TimingISR function you write.
* Timer1.stop(); // Timer 1 stops timing
* Timer1.start(); // Timer 1 start
* 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;