eagler8 发表于 2019-9-28 10:58:11

eagler8 发表于 2019-9-28 15:21:02

多功能扩展版系列实验分为三个主要部分:
1。基本输入/输出
2。读数传感器
3。实际应用程序

第1部分演示了多功能扩展按钮、蜂鸣器和显示器的易用性,通过使用扩展库使用,因此更容易集中于应用。

第2部分演示如何使用扩展库从外部传感器读取值,例如温度、声纳和运动传感器,以及如何处理来自外部的电子脉冲来源。

第3部分探讨使用库和多功能屏蔽的工作应用程序:
24小时闹钟
心脏监护仪–(需要心脏脉冲传感器)
倒数计时器
地面倾斜水平指示器–(需要MPU6050运动传感器)
声纳测距仪–(需要HC SR04声纳模块)
车速表–(需要磁铁和簧片开关)
每一个都有建立和扩大的空间,但把这个留给你们来发挥。

eagler8 发表于 2019-9-28 15:25:07

eagler8 发表于 2019-9-28 15:36:01

/*
【Arduino】108种传感器模块系列实验(资料+代码+图形+仿真)
实验一百三十:XD-203多功能扩展板Multi-function Shield模块(12合1版)
项目一:4个短哔声,重复3次
*/

#include <TimerOne.h>
#include <Wire.h>
#include <MultiFuncShield.h>

void setup() {
// put your setup code here, to run once:
Timer1.initialize();
MFS.initialize(&Timer1); // initialize multi-function shield library
// NOTE beep control is performed in the background, i.e. beep() is non blocking.
// short beep for 200 milliseconds
MFS.beep();
delay(1000);
// 4 short beeps, repeated 3 times.
MFS.beep(5, // beep for 50 milliseconds
5, // silent for 50 milliseconds
4, // repeat above cycle 4 times
3, // loop 3 times
50 // wait 500 milliseconds between loop
);
}

void loop() {
// put your main code here, to run repeatedly:
}

eagler8 发表于 2019-9-28 15:53:28

/*
【Arduino】108种传感器模块系列实验(资料+代码+图形+仿真)
实验一百三十:XD-203多功能扩展板Multi-function Shield模块(12合1版)
项目二:显示串行监视器窗口中按钮按下的类型。检查发生了什么,按或者把多个按钮放在一起,持续时间不同。
*/

#include <TimerOne.h>
#include <Wire.h>
#include <MultiFuncShield.h>

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Timer1.initialize();
MFS.initialize(&Timer1); // initialize multi-function shield library
}

void loop() {
// put your main code here, to run repeatedly:
byte btn = MFS.getButton(); // Normally it is sufficient to compare the return
// value to predefined macros, e.g.
BUTTON_1_PRESSED;
//BUTTON_1_LONG_PRESSED etc.
if (btn)
{
byte buttonNumber = btn & B00111111;
byte buttonAction = btn & B11000000;
Serial.print("BUTTON_");
Serial.write(buttonNumber + '0');
Serial.print("_");
if (buttonAction == BUTTON_PRESSED_IND)
{
Serial.println("PRESSED");
}
else if (buttonAction == BUTTON_SHORT_RELEASE_IND)
{
Serial.println("SHORT_RELEASE");
}
else if (buttonAction == BUTTON_LONG_PRESSED_IND)
{
Serial.println("LONG_PRESSED");
}
else if (buttonAction == BUTTON_LONG_RELEASE_IND)
{
Serial.println("LONG_RELEASE");
}
}
}

eagler8 发表于 2019-9-28 15:56:36

eagler8 发表于 2019-9-28 16:06:06

本帖最后由 eagler8 于 2019-9-28 16:11 编辑

/*
【Arduino】108种传感器模块系列实验(资料+代码+图形+仿真)
实验一百三十:XD-203多功能扩展板Multi-function Shield模块(12合1版)
项目三:数字显示,计数器
*/

#include <TimerOne.h>
#include <Wire.h>
#include <MultiFuncShield.h>
void setup() {
// put your setup code here, to run once:
Timer1.initialize();
MFS.initialize(&Timer1); // initialize multi-function shield library
MFS.write("Hi");
delay(2000);
MFS.write(-273);
delay(2000);
MFS.write(3.141, 2); // display to 2 decimal places.
delay(2000);
}
int counter=0;
byte ended = false;

void loop() {
// put your main code here, to run repeatedly:
if (counter < 200)
{
MFS.write((int)counter);
counter++;
}
else if (!ended)
{
ended = true;
MFS.write("End");
MFS.blinkDisplay(DIGIT_ALL, ON);
}
delay(50);
}

eagler8 发表于 2019-9-28 16:16:32

/*
【Arduino】108种传感器模块系列实验(资料+代码+图形+仿真)
实验一百三十:XD-203多功能扩展板Multi-function Shield模块(12合1版)
项目四:控制板载LED
*/

#include <TimerOne.h>
#include <Wire.h>
#include <MultiFuncShield.h>

void setup() {
// put your setup code here, to run once:
Timer1.initialize();
MFS.initialize(&Timer1); // initialize multi-function shield library
MFS.writeLeds(LED_ALL, ON);
delay(2000);
MFS.blinkLeds(LED_1 | LED_2, ON);
delay(2000);
MFS.blinkLeds(LED_1 | LED_2, OFF);
MFS.blinkLeds(LED_3 | LED_4, ON);
delay(2000);
MFS.blinkLeds(LED_ALL, ON);
delay(2000);
MFS.blinkLeds(LED_ALL, OFF);
MFS.writeLeds(LED_ALL, OFF);

}
void loop() {
// put your main code here, to run repeatedly:
}

eagler8 发表于 2019-9-28 16:24:59

页: 1 [2]
查看完整版本: 【Arduino】108种传感器系列实验(130)---XD-203多功能扩展板