Skip to content

Commit b206454

Browse files
committed
add some files.
1 parent 6d76af6 commit b206454

File tree

120 files changed

+15948
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+15948
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
Helloworld
3+
4+
This example code is in the public domain.
5+
6+
http://
7+
*/
8+
9+
10+
// the setup routine runs once when you press reset:
11+
void setup()
12+
{
13+
// initialize serial communication at 115200 bits per second:
14+
Serial.begin(115200);
15+
while (!Serial)
16+
{
17+
; // wait for serial port to connect. Needed for native USB port only
18+
}
19+
// serial print hello world.
20+
Serial.println("Hello world!");
21+
}
22+
23+
// the loop routine runs over and over again forever:
24+
void loop()
25+
{
26+
Serial.println("Hello world!");
27+
delay(2000);
28+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <WiFi.h>
2+
3+
const char* ssid = "FAST_HAHA";
4+
const char* password = "15671677156ting";
5+
6+
void setup()
7+
{
8+
Serial.begin(115200);
9+
WiFi.begin(ssid,password);
10+
while(WiFi.status() != WL_CONNECTED){
11+
// statement
12+
delay(500);
13+
Serial.println("Connecting to WiFi...");
14+
}
15+
16+
Serial.println("Connected to the WiFi network");
17+
18+
}
19+
20+
void loop()
21+
{
22+
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <WiFi.h>
2+
3+
const char* ssid = "FAST_HAHA";
4+
const char* password = "15671677156ting";
5+
6+
void setup()
7+
{
8+
Serial.begin(115200);
9+
WiFi.begin(ssid,password);
10+
while(WiFi.status() != WL_CONNECTED){
11+
// statement
12+
delay(500);
13+
Serial.println("Connecting to WiFi...");
14+
}
15+
16+
Serial.println("Connected to the WiFi network");
17+
18+
}
19+
20+
void loop()
21+
{
22+
23+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#include <WiFi.h>
2+
3+
const char* ssid = "FAST_HAHA";
4+
const char* password = "15671677156ting";
5+
6+
void setup()
7+
{
8+
Serial.begin(115200);
9+
10+
scanNetworks();
11+
connectToNetwork();
12+
13+
Serial.println(WiFi.localIP());
14+
Serial.println(WiFi.macAddress());
15+
WiFi.disconnect(true);
16+
Serial.println(WiFi.localIP());
17+
18+
}
19+
20+
void loop()
21+
{
22+
23+
}
24+
25+
String translateEncryptionType(wifi_auth_mode_t encryptionType)
26+
{
27+
switch (encryptionType)
28+
{
29+
case (WIFI_AUTH_OPEN):
30+
return "Open";
31+
case (WIFI_AUTH_WEP):
32+
return "WEP";
33+
case (WIFI_AUTH_WPA_PSK):
34+
return "WPA_PSK";
35+
case (WIFI_AUTH_WPA2_PSK):
36+
return "WPA2_PSK";
37+
case (WIFI_AUTH_WPA_WPA2_PSK):
38+
return "WPA_WPA2_PSK";
39+
case (WIFI_AUTH_WPA2_ENTERPRISE):
40+
return "WPA2_ENTERPRISE";
41+
}
42+
}
43+
44+
void scanNetworks()
45+
{
46+
int numberOfNetworks = WiFi.scanNetworks();
47+
Serial.print("Number of networks found: ");
48+
Serial.println(numberOfNetworks);
49+
for (int i = 0; i < numberOfNetworks; i++)
50+
{
51+
Serial.print("Network name: ");
52+
Serial.println(WiFi.SSID(i));
53+
Serial.print("Signal strength: ");
54+
Serial.println(WiFi.RSSI(i));
55+
Serial.print("MAC address: ");
56+
Serial.println(WiFi.BSSIDstr(i));
57+
Serial.print("Encryption type: ");
58+
String encryptionTypeDescription = translateEncryptionType(WiFi.encryptionType(i));
59+
Serial.println(encryptionTypeDescription);
60+
Serial.println("-----------------------");
61+
}
62+
63+
}
64+
65+
void connectToNetwork()
66+
{
67+
WiFi.begin(ssid, password);
68+
while (WiFi.status() != WL_CONNECTED) {
69+
delay(1000);
70+
Serial.println("Establishing connection to WiFi..");
71+
}
72+
Serial.println("Connected to network");
73+
74+
}
75+
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#include <WiFi.h>
2+
3+
const char* ssid = "FAST_HAHA";
4+
const char* password = "15671677156ting";
5+
6+
void setup()
7+
{
8+
Serial.begin(115200);
9+
WiFi.mode(WIFI_STA);
10+
WiFi.disconnect();
11+
delay(100);
12+
scanNetworks();
13+
connectToNetwork();
14+
15+
Serial.println(WiFi.localIP());
16+
Serial.println(WiFi.macAddress());
17+
WiFi.disconnect(true);
18+
Serial.println(WiFi.localIP());
19+
20+
}
21+
22+
void loop()
23+
{
24+
25+
}
26+
27+
String translateEncryptionType(wifi_auth_mode_t encryptionType)
28+
{
29+
switch (encryptionType)
30+
{
31+
case (WIFI_AUTH_OPEN):
32+
return "Open";
33+
case (WIFI_AUTH_WEP):
34+
return "WEP";
35+
case (WIFI_AUTH_WPA_PSK):
36+
return "WPA_PSK";
37+
case (WIFI_AUTH_WPA2_PSK):
38+
return "WPA2_PSK";
39+
case (WIFI_AUTH_WPA_WPA2_PSK):
40+
return "WPA_WPA2_PSK";
41+
case (WIFI_AUTH_WPA2_ENTERPRISE):
42+
return "WPA2_ENTERPRISE";
43+
}
44+
}
45+
46+
void scanNetworks()
47+
{
48+
int numberOfNetworks = WiFi.scanNetworks();
49+
Serial.println("Scan Done!");
50+
Serial.print("Number of networks found: ");
51+
Serial.println(numberOfNetworks);
52+
for (int i = 0; i < numberOfNetworks; i++)
53+
{
54+
Serial.print("Network name: ");
55+
Serial.println(WiFi.SSID(i));
56+
Serial.print("Signal strength: ");
57+
Serial.println(WiFi.RSSI(i));
58+
Serial.print("MAC address: ");
59+
Serial.println(WiFi.BSSIDstr(i));
60+
Serial.print("Encryption type: ");
61+
String encryptionTypeDescription = translateEncryptionType(WiFi.encryptionType(i));
62+
Serial.println(encryptionTypeDescription);
63+
Serial.println("-----------------------");
64+
}
65+
66+
}
67+
68+
void connectToNetwork()
69+
{
70+
WiFi.begin(ssid, password);
71+
while (WiFi.status() != WL_CONNECTED) {
72+
delay(1000);
73+
Serial.println("Establishing connection to WiFi..");
74+
}
75+
Serial.println("Connected to network");
76+
77+
}
78+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <WiFi.h>
2+
3+
const char *ssid = "ESP32AP";
4+
const char *password = "12345678";
5+
6+
void setup()
7+
{
8+
Serial.begin(115200);
9+
WiFi.softAP(ssid, password);
10+
delay(100);
11+
Serial.print("IP address: ");
12+
Serial.println(WiFi.softAPIP());
13+
14+
}
15+
16+
void loop()
17+
{
18+
19+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
Serial for UART0
3+
4+
This example code is in the public domain.
5+
6+
http://
7+
*/
8+
9+
10+
char inByte = 0; // incoming serial byte
11+
// the setup routine runs once when you press reset:
12+
void setup()
13+
{
14+
// initialize serial communication at 115200 bits per second:
15+
Serial.begin(115200);
16+
while (!Serial)
17+
{
18+
; // wait for serial port to connect. Needed for native USB port only
19+
}
20+
// serial print hello world.
21+
Serial.println("Hello world!");
22+
}
23+
24+
// the loop routine runs over and over again forever:
25+
void loop()
26+
{
27+
// print out the value if Serial available.
28+
if (Serial.available() > 0)
29+
{
30+
// get incoming byte:
31+
inByte = Serial.read();
32+
// send back values:
33+
Serial.write(inByte);
34+
}
35+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
Serial for UART2
3+
- 使用"HardwareSerial"类进行串行通信。它有一些重要的接口:
4+
- HardwareSerial(int uart_nr):这是HardwareSerial的构造函数,其中uart_nr为0,1或2,所以我们有最多3个串行端口。
5+
6+
- void begin(unsigned long baud,uint32_t config = SERIAL_8N1,int8_t rxPin = -1,int8_t txPin = -1):用初始化串口:波特率,串口模式(默认为SERIAL_8N1),rxPin和txPin(如果您保留这些参数为空库将使用默认引脚)。
7+
- available():获取从串口读取可用的字节数(字符)。
8+
- print():将可读的数据使用ASCII打印到串行端口。
9+
- println():将数据使用ASCII打印到串行端口,后跟回车符(ASCII 13或'\ r')和换行符(ASCII 10或'\ n')。
10+
- read():读取Rx引脚上输入的串行数据。
11+
- readStringUntil():将串行缓冲区中的字符读入字符串,直到遇到终止符。
12+
- 因为Arduino库创建了一个默认实例HardwareSerial Serial(0),因此您可以直接使用创建的Serial对象,而无需自己创建实例。
13+
- 为了使用更多的串行端口,您只需创建另一个HardwareSerial实例,例如:HardwareSerial Serial1(1)或HardwareSerial Serial2(2),然后常用方法使用它们。
14+
15+
This example code is in the public domain.
16+
17+
http://www.afantor.cc
18+
*/
19+
20+
HardwareSerial Serial2(2);
21+
22+
int8_t U2rxPin = 16;
23+
int8_t U2txPin = 17;
24+
25+
char inByte = 0; // incoming serial byte
26+
// the setup routine runs once when you press reset:
27+
void setup()
28+
{
29+
// initialize serial communication at 115200 bits per second:
30+
Serial2.begin(115200,SERIAL_8N1,U2rxPin,U2txPin);
31+
while (!Serial2)
32+
{
33+
; // wait for serial port to connect. Needed for native USB port only
34+
}
35+
// serial print hello world.
36+
Serial2.println("Hello world!");
37+
}
38+
39+
// the loop routine runs over and over again forever:
40+
void loop()
41+
{
42+
// print out the value if Serial available.
43+
if (Serial2.available() > 0)
44+
{
45+
// get incoming byte:
46+
inByte = Serial2.read();
47+
// send back values:
48+
Serial2.write(inByte);
49+
}
50+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
Serial for UART1
3+
4+
This example code is in the public domain.
5+
6+
http://www.afantor.cc
7+
*/
8+
9+
HardwareSerial Serial1(1);
10+
11+
int8_t U1rxPin = 16;
12+
int8_t U1txPin = 4;
13+
14+
char inByte = 0; // incoming serial byte
15+
// the setup routine runs once when you press reset:
16+
void setup()
17+
{
18+
// initialize serial communication at 115200 bits per second:
19+
Serial1.begin(115200,SERIAL_8N1,U1rxPin,U1txPin);
20+
while (!Serial1)
21+
{
22+
; // wait for serial port to connect. Needed for native USB port only
23+
}
24+
// serial print hello world.
25+
Serial1.println("Hello world!");
26+
}
27+
28+
// the loop routine runs over and over again forever:
29+
void loop()
30+
{
31+
// print out the value if Serial available.
32+
if (Serial1.available() > 0)
33+
{
34+
// get incoming byte:
35+
inByte = Serial1.read();
36+
// send back values:
37+
Serial1.write(inByte);
38+
}
39+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
int ledPin = 14;
3+
4+
void setup()
5+
{
6+
pinMode(ledPin, OUTPUT);
7+
}
8+
9+
void loop()
10+
{
11+
digitalWrite(ledPin, HIGH);
12+
delay(1000);
13+
digitalWrite(ledPin, LOW);
14+
delay(1000);
15+
}

0 commit comments

Comments
 (0)