Created
May 2, 2020 17:44
-
-
Save youjunjer/1740f19bd240f8c606aad9258632971c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*======= ========= ========= ========= ========= ========= ========= ========= | |
Project : ESProMatrix-USBPP | |
File : ESProMatrix-USBPP.ino | |
Date : 2019/05/01 | |
Version : 0.0.1 | |
Author : Samui Young | |
Company : Chipfans Technology Co.,Ltd. | |
MCU : NodeMCU ESP32-S | |
Details : Demo of USB power port | |
--------- --------- --------- --------- --------- --------- --------- --------- | |
Notice : | |
- when use Serial function : | |
. 由於USB Power用了GPIO 1,3是Serial的TX RX,所以使用USB Power時,無法使用Serial | |
. must follow the following process | |
. Serial.end(); | |
. pinMode(UsbPP2, INPUT); | |
. pinMode(UsbPP2, OUTPUT); | |
========= ========= ========= ========= ========= ========= ========= ========*/ | |
int UsbPP1 = 1; // P1: GPIO1 | |
int UsbPP2 = 3; // P1: GPIO3 | |
void setup() { | |
pinMode(UsbPP1, OUTPUT); | |
pinMode(UsbPP2, OUTPUT); | |
for (int i = 0 ; i < 3 ; i++) | |
{ | |
digitalWrite(UsbPP1, LOW); | |
digitalWrite(UsbPP2, LOW); | |
delay(500); | |
digitalWrite(UsbPP1, HIGH); | |
digitalWrite(UsbPP2, HIGH); | |
delay(500); | |
} | |
digitalWrite(UsbPP1, LOW); | |
digitalWrite(UsbPP2, LOW); | |
} | |
void loop() { | |
//兩秒一次更換開關 | |
digitalWrite(UsbPP1, HIGH); | |
digitalWrite(UsbPP2, LOW); | |
delay(2000); | |
digitalWrite(UsbPP1, LOW); | |
digitalWrite(UsbPP2, HIGH); | |
delay(2000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment