This commit is contained in:
Tinyu
2021-08-16 12:18:12 +08:00
parent bc3cce2bad
commit 1d5e43aefe
2 changed files with 44 additions and 25 deletions
@@ -1,25 +1,30 @@
/*
Description: Detect the current OP 90/180 Unit Photoelectric switch status.
*******************************************************************************
* Copyright (c) 2021 by M5Stack
* Equipped with M5Core sample source code
* 配套 M5Core 示例源代码
* Visit the website for more informationhttps://docs.m5stack.com/en/core/gray
* 获取更多资料请访问:https://docs.m5stack.com/zh_CN/core/gray
*
* describeOP 180/90. 非接触式光电限位开关
* date2021/8/11
*******************************************************************************
Please connect to Port B(36),Detect the current OP 90/180 Unit Photoelectric switch status.
请连接端口B(36),检测当前OP 90/180单元光电开关状态。
*/
#include <M5Stack.h>
void setup() {
// put your setup code here, to run once:
M5.begin();
M5.Power.begin();
//Wire.begin();
M5.Lcd.setCursor(120, 10, 4);
M5.begin(); //Init M5Stack. 初始化M5Stack
M5.Power.begin(); //Init power 初始化电源模块
M5.lcd.setTextSize(2); //Set the text size to 2. 设置文字大小为2
M5.Lcd.setCursor(80, 10); //Set the cursor at (80,10). 将光标设置在(80,10)处
M5.Lcd.println("90/180 OPTICAL");
pinMode(36,INPUT_PULLUP);
pinMode(36,INPUT_PULLUP); //Set pin 36 to input pull-up mode. 设置36号引脚为输入上拉模式
}
void loop() {
// put your main code here, to run repeatedly:
M5.Lcd.setCursor(80, 120, 4);
M5.Lcd.printf("ir receive: %d",digitalRead(36));
M5.Lcd.setCursor(80, 120);
M5.Lcd.printf("IR Receive: %d",digitalRead(36)); //Output the value of pin 36. 输出36号引脚的值
}
+25 -11
View File
@@ -1,24 +1,38 @@
/*
Description: Use RELAY to switch on and off the circuit.
*******************************************************************************
* Copyright (c) 2021 by M5Stack
* Equipped with M5Core sample source code
* 配套 M5Core 示例源代码
* Visit the website for more informationhttps://docs.m5stack.com/en/core/gray
* 获取更多资料请访问:https://docs.m5stack.com/zh_CN/core/gray
*
* describeRelay. 继电器
* date2021/8/16
*******************************************************************************
Please connect to Port B(26),Use RELAY to switch on and off the circuit.
请连接端口B(26),使用继电器开关电路。
*/
#include <M5Stack.h>
void setup() {
M5.begin();
M5.Power.begin();
M5.Lcd.clear(BLACK);
M5.Lcd.setTextFont(4);
M5.Lcd.setTextColor(YELLOW, BLACK);
M5.Lcd.setCursor(50, 0, 4);
M5.begin(); //Init M5Stack. 初始化M5Stack
M5.Power.begin(); //Init power 初始化电源模块
M5.lcd.setTextSize(2); //Set the text size to 2. 设置文字大小为2
M5.Lcd.setCursor(50, 0);
M5.Lcd.println(("Relay Example"));
//disable the speak noise
dacWrite(25, 0);
dacWrite(25, 0); //disable the speak noise
pinMode(26, OUTPUT);
}
void loop(void) {
M5.Lcd.setCursor(100, 40);
M5.Lcd.print("ON");
digitalWrite(26, HIGH);
delay(500);
delay(1000);
M5.Lcd.fillRect(100,40,60,50,BLACK);
M5.Lcd.print("OFF");
digitalWrite(26, LOW);
delay(500);
delay(1000);
M5.Lcd.fillRect(100,40,60,50,BLACK);
}