From 1d5e43aefe3e7cd5d55d96edb63c2ec4fa59b317 Mon Sep 17 00:00:00 2001 From: Tinyu Date: Mon, 16 Aug 2021 12:18:12 +0800 Subject: [PATCH] op,relay --- .../OP90.180_ITR9606/OP90.180_ITR9606.ino | 33 +++++++++-------- examples/Unit/RELAY/RELAY.ino | 36 +++++++++++++------ 2 files changed, 44 insertions(+), 25 deletions(-) diff --git a/examples/Unit/OP90.180_ITR9606/OP90.180_ITR9606.ino b/examples/Unit/OP90.180_ITR9606/OP90.180_ITR9606.ino index c45dd28..cee18be 100644 --- a/examples/Unit/OP90.180_ITR9606/OP90.180_ITR9606.ino +++ b/examples/Unit/OP90.180_ITR9606/OP90.180_ITR9606.ino @@ -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 information:https://docs.m5stack.com/en/core/gray +* 获取更多资料请访问:https://docs.m5stack.com/zh_CN/core/gray +* +* describe:OP 180/90. 非接触式光电限位开关 +* date:2021/8/11 +******************************************************************************* + Please connect to Port B(36),Detect the current OP 90/180 Unit Photoelectric switch status. + 请连接端口B(36),检测当前OP 90/180单元光电开关状态。 */ #include - 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号引脚的值 } diff --git a/examples/Unit/RELAY/RELAY.ino b/examples/Unit/RELAY/RELAY.ino index 674da9d..4b34546 100644 --- a/examples/Unit/RELAY/RELAY.ino +++ b/examples/Unit/RELAY/RELAY.ino @@ -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 information:https://docs.m5stack.com/en/core/gray +* 获取更多资料请访问:https://docs.m5stack.com/zh_CN/core/gray +* +* describe:Relay. 继电器 +* date:2021/8/16 +******************************************************************************* + Please connect to Port B(26),Use RELAY to switch on and off the circuit. + 请连接端口B(26),使用继电器开关电路。 */ + #include 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); }