├── bt_sum └── bt_sum.ino ├── bt_slider └── bt_slider.ino ├── bt_matrix └── bt_matrix.ino ├── WiFiScan └── WiFiScan.ino ├── WiFiClientEvents └── WiFiClientEvents.ino └── SimpleWiFiServer └── SimpleWiFiServer.ino /bt_sum/bt_sum.ino: -------------------------------------------------------------------------------- 1 | #include "BluetoothSerial.h" 2 | #include 3 | #include 4 | BluetoothSerial SerialBT; 5 | LiquidCrystal_I2C lcd(0x20, 16, 2); 6 | 7 | void setup() { 8 | Serial.begin(115200); 9 | SerialBT.begin("Name"); 10 | lcd.init(); 11 | lcd.backlight(); 12 | lcd.print("Hello, World"); 13 | } 14 | 15 | void loop() { 16 | if (SerialBT.available()>0) { 17 | char data = SerialBT.read(); 18 | Serial.write(data); 19 | if (data == '1') { 20 | int data_i = SerialBT.parseInt(); 21 | lcd.clear(); 22 | lcd.setCursor(0,0); 23 | lcd.print('result = '); 24 | lcd.print(data_i); 25 | } 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /bt_slider/bt_slider.ino: -------------------------------------------------------------------------------- 1 | #include "BluetoothSerial.h" 2 | BluetoothSerial SerialBT; 3 | int ledChannel = 0; 4 | int buzzerChannel = 1; 5 | int freq = 2000; 6 | int freq2 = 0; 7 | int resolution = 8; 8 | int dutyCycle = 0; 9 | 10 | void setup() { 11 | Serial.begin(115200); 12 | SerialBT.begin("Name"); //이름 넣기 13 | pinMode(15,OUTPUT); 14 | digitalWrite(15, LOW); 15 | ledcSetup(ledChannel, freq, resolution); 16 | ledcAttachPin(15, ledChannel); 17 | ledcAttachPin(25, buzzerChannel); 18 | pinMode(2, OUTPUT); 19 | digitalWrite(2, LOW); 20 | } 21 | 22 | void loop() { 23 | if (SerialBT.available()>0) { 24 | int data1 = SerialBT.read(); 25 | int data2 = SerialBT.read(); 26 | int final_data = data1 + (data2 * 256); 27 | Serial.write(final_data); 28 | Serial.println(final_data); 29 | if (final_data >= 1000 && final_data <= 1255) { 30 | dutyCycle = final_data - 1000; 31 | ledcWrite(ledChannel, dutyCycle); 32 | } else if (final_data>=2000 && final_data <= 3023) { 33 | digitalWrite(2, HIGH); 34 | freq2 = final_data - 2000; 35 | ledcWriteTone(buzzerChannel, freq2); 36 | delay(20); 37 | digitalWrite(2, LOW); 38 | } 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /bt_matrix/bt_matrix.ino: -------------------------------------------------------------------------------- 1 | #include "BluetoothSerial.h" 2 | #include 3 | #include 4 | BluetoothSerial SerialBT; 5 | Adafruit_IS31FL3731 matrix = Adafruit_IS31FL3731(); 6 | int matrix_speed = 200; 7 | int matrix_br = 50; 8 | 9 | void setup() { 10 | Serial.begin(115200); 11 | SerialBT.begin("ESP32_17"); //이름 넣기 12 | matrix.begin(); 13 | matrix.setTextColor(matrix_br); 14 | } 15 | 16 | void loop() { 17 | char temp[10]; 18 | memset(temp, 0, sizeof(temp)); 19 | if (SerialBT.available()>0) { 20 | char data = SerialBT.read(); 21 | Serial.write(data); 22 | if (data == '1') { 23 | SerialBT.readBytes(temp, 10); 24 | Serial.write(temp); 25 | for (int x = 0; x>= -30; x--) { 26 | matrix.clear(); 27 | matrix.setCursor(x, 1); 28 | matrix.print(temp); 29 | delay(matrix_speed); 30 | } 31 | matrix.clear(); 32 | } 33 | 34 | if (data == '2') { 35 | int speed = SerialBT.read(); 36 | matrix_speed = (200-(speed * 2)); 37 | Serial.println("speed"); 38 | Serial.println(matrix_speed); 39 | } 40 | 41 | if (data == '3') { 42 | matrix_br = SerialBT.read(); 43 | matrix.setTextColor(matrix_br); 44 | Serial.println("bright"); 45 | Serial.println(matrix_br); 46 | } 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /WiFiScan/WiFiScan.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * This sketch demonstrates how to scan WiFi networks. 3 | * The API is almost the same as with the WiFi Shield library, 4 | * the most obvious difference being the different file you need to include: 5 | */ 6 | #include "WiFi.h" 7 | 8 | void setup() 9 | { 10 | Serial.begin(115200); 11 | 12 | // Set WiFi to station mode and disconnect from an AP if it was previously connected 13 | WiFi.mode(WIFI_STA); 14 | WiFi.disconnect(); 15 | delay(100); 16 | 17 | Serial.println("Setup done"); 18 | } 19 | 20 | void loop() 21 | { 22 | Serial.println("scan start"); 23 | 24 | // WiFi.scanNetworks will return the number of networks found 25 | int n = WiFi.scanNetworks(); 26 | Serial.println("scan done"); 27 | if (n == 0) { 28 | Serial.println("no networks found"); 29 | } else { 30 | Serial.print(n); 31 | Serial.println(" networks found"); 32 | for (int i = 0; i < n; ++i) { 33 | // Print SSID and RSSI for each network found 34 | Serial.print(i + 1); 35 | Serial.print(": "); 36 | Serial.print(WiFi.SSID(i)); 37 | Serial.print(" ("); 38 | Serial.print(WiFi.RSSI(i)); 39 | Serial.print(")"); 40 | Serial.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN)?" ":"*"); 41 | delay(10); 42 | } 43 | } 44 | Serial.println(""); 45 | 46 | // Wait a bit before scanning again 47 | delay(5000); 48 | } 49 | -------------------------------------------------------------------------------- /WiFiClientEvents/WiFiClientEvents.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * This sketch shows the WiFi event usage 3 | * 4 | */ 5 | 6 | /* 7 | * WiFi Events 8 | 9 | SYSTEM_EVENT_WIFI_READY < ESP32 WiFi ready 10 | SYSTEM_EVENT_SCAN_DONE < ESP32 finish scanning AP 11 | SYSTEM_EVENT_STA_START < ESP32 station start 12 | SYSTEM_EVENT_STA_STOP < ESP32 station stop 13 | SYSTEM_EVENT_STA_CONNECTED < ESP32 station connected to AP 14 | SYSTEM_EVENT_STA_DISCONNECTED < ESP32 station disconnected from AP 15 | SYSTEM_EVENT_STA_AUTHMODE_CHANGE < the auth mode of AP connected by ESP32 station changed 16 | SYSTEM_EVENT_STA_GOT_IP < ESP32 station got IP from connected AP 17 | SYSTEM_EVENT_STA_LOST_IP < ESP32 station lost IP and the IP is reset to 0 18 | SYSTEM_EVENT_STA_WPS_ER_SUCCESS < ESP32 station wps succeeds in enrollee mode 19 | SYSTEM_EVENT_STA_WPS_ER_FAILED < ESP32 station wps fails in enrollee mode 20 | SYSTEM_EVENT_STA_WPS_ER_TIMEOUT < ESP32 station wps timeout in enrollee mode 21 | SYSTEM_EVENT_STA_WPS_ER_PIN < ESP32 station wps pin code in enrollee mode 22 | SYSTEM_EVENT_AP_START < ESP32 soft-AP start 23 | SYSTEM_EVENT_AP_STOP < ESP32 soft-AP stop 24 | SYSTEM_EVENT_AP_STACONNECTED < a station connected to ESP32 soft-AP 25 | SYSTEM_EVENT_AP_STADISCONNECTED < a station disconnected from ESP32 soft-AP 26 | SYSTEM_EVENT_AP_PROBEREQRECVED < Receive probe request packet in soft-AP interface 27 | SYSTEM_EVENT_GOT_IP6 < ESP32 station or ap or ethernet interface v6IP addr is preferred 28 | SYSTEM_EVENT_ETH_START < ESP32 ethernet start 29 | SYSTEM_EVENT_ETH_STOP < ESP32 ethernet stop 30 | SYSTEM_EVENT_ETH_CONNECTED < ESP32 ethernet phy link up 31 | SYSTEM_EVENT_ETH_DISCONNECTED < ESP32 ethernet phy link down 32 | SYSTEM_EVENT_ETH_GOT_IP < ESP32 ethernet got IP from connected AP 33 | SYSTEM_EVENT_MAX 34 | */ 35 | 36 | #include 37 | 38 | const char* ssid = "your-ssid"; 39 | const char* password = "your-password"; 40 | 41 | 42 | void WiFiEvent(WiFiEvent_t event) 43 | { 44 | Serial.printf("[WiFi-event] event: %d\n", event); 45 | 46 | switch (event) 47 | { 48 | case SYSTEM_EVENT_STA_GOT_IP: 49 | Serial.println("WiFi connected"); 50 | Serial.println("IP address: "); 51 | Serial.println(WiFi.localIP()); 52 | break; 53 | case SYSTEM_EVENT_STA_DISCONNECTED: 54 | Serial.println("WiFi lost connection"); 55 | break; 56 | } 57 | } 58 | 59 | void WiFiGotIP(WiFiEvent_t event, WiFiEventInfo_t info) 60 | { 61 | Serial.println("WiFi connected"); 62 | Serial.println("IP address: "); 63 | Serial.println(IPAddress(info.got_ip.ip_info.ip.addr)); 64 | } 65 | 66 | void setup() 67 | { 68 | Serial.begin(115200); 69 | 70 | // delete old config 71 | WiFi.disconnect(true); 72 | 73 | delay(1000); 74 | 75 | // Examples of diffrent ways to register wifi events 76 | WiFi.onEvent(WiFiEvent); 77 | WiFi.onEvent(WiFiGotIP, WiFiEvent_t::SYSTEM_EVENT_STA_GOT_IP); 78 | WiFiEventId_t eventID = WiFi.onEvent([](WiFiEvent_t event, WiFiEventInfo_t info){ 79 | Serial.print("WiFi lost connection. Reason: "); 80 | Serial.println(info.disconnected.reason); 81 | }, WiFiEvent_t::SYSTEM_EVENT_STA_DISCONNECTED); 82 | 83 | // Remove WiFi event 84 | Serial.print("WiFi Event ID: "); 85 | Serial.println(eventID); 86 | // WiFi.removeEvent(eventID); 87 | 88 | WiFi.begin(ssid, password); 89 | 90 | Serial.println(); 91 | Serial.println(); 92 | Serial.println("Wait for WiFi... "); 93 | } 94 | 95 | void loop() 96 | { 97 | delay(1000); 98 | } 99 | -------------------------------------------------------------------------------- /SimpleWiFiServer/SimpleWiFiServer.ino: -------------------------------------------------------------------------------- 1 | /* 2 | WiFi Web Server LED Blink 3 | 4 | A simple web server that lets you blink an LED via the web. 5 | This sketch will print the IP address of your WiFi Shield (once connected) 6 | to the Serial monitor. From there, you can open that address in a web browser 7 | to turn on and off the LED on pin 5. 8 | 9 | If the IP address of your shield is yourAddress: 10 | http://yourAddress/H turns the LED on 11 | http://yourAddress/L turns it off 12 | 13 | This example is written for a network using WPA encryption. For 14 | WEP or WPA, change the Wifi.begin() call accordingly. 15 | 16 | Circuit: 17 | * WiFi shield attached 18 | * LED attached to pin 5 19 | 20 | created for arduino 25 Nov 2012 21 | by Tom Igoe 22 | 23 | ported for sparkfun esp32 24 | 31.01.2017 by Jan Hendrik Berlin 25 | 26 | */ 27 | 28 | #include 29 | 30 | const char* ssid = "robot309"; 31 | const char* password = "robot123"; 32 | 33 | WiFiServer server(80); 34 | 35 | void setup() 36 | { 37 | Serial.begin(115200); 38 | pinMode(15, OUTPUT); // set the LED pin mode 39 | 40 | delay(10); 41 | 42 | // We start by connecting to a WiFi network 43 | 44 | Serial.println(); 45 | Serial.println(); 46 | Serial.print("Connecting to "); 47 | Serial.println(ssid); 48 | 49 | WiFi.begin(ssid, password); 50 | 51 | while (WiFi.status() != WL_CONNECTED) { 52 | delay(500); 53 | Serial.print("."); 54 | } 55 | 56 | Serial.println(""); 57 | Serial.println("WiFi connected."); 58 | Serial.println("IP address: "); 59 | Serial.println(WiFi.localIP()); 60 | 61 | server.begin(); 62 | 63 | } 64 | 65 | int value = 0; 66 | 67 | void loop(){ 68 | WiFiClient client = server.available(); // listen for incoming clients 69 | 70 | if (client) { // if you get a client, 71 | Serial.println("New Client."); // print a message out the serial port 72 | String currentLine = ""; // make a String to hold incoming data from the client 73 | while (client.connected()) { // loop while the client's connected 74 | if (client.available()) { // if there's bytes to read from the client, 75 | char c = client.read(); // read a byte, then 76 | Serial.write(c); // print it out the serial monitor 77 | if (c == '\n') { // if the byte is a newline character 78 | 79 | // if the current line is blank, you got two newline characters in a row. 80 | // that's the end of the client HTTP request, so send a response: 81 | if (currentLine.length() == 0) { 82 | // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK) 83 | // and a content-type so the client knows what's coming, then a blank line: 84 | client.println("HTTP/1.1 200 OK"); 85 | client.println("Content-type:text/html"); 86 | client.println(); 87 | 88 | // the content of the HTTP response follows the header: 89 | client.print("Click here to turn the LED on pin 5 on.
"); 90 | client.print("Click here to turn the LED on pin 5 off.
"); 91 | 92 | // The HTTP response ends with another blank line: 93 | client.println(); 94 | // break out of the while loop: 95 | break; 96 | } else { // if you got a newline, then clear currentLine: 97 | currentLine = ""; 98 | } 99 | } else if (c != '\r') { // if you got anything else but a carriage return character, 100 | currentLine += c; // add it to the end of the currentLine 101 | } 102 | 103 | // Check to see if the client request was "GET /H" or "GET /L": 104 | if (currentLine.endsWith("GET /H")) { 105 | digitalWrite(15, HIGH); // GET /H turns the LED on 106 | } 107 | if (currentLine.endsWith("GET /L")) { 108 | digitalWrite(15, LOW); // GET /L turns the LED off 109 | } 110 | } 111 | } 112 | // close the connection: 113 | client.stop(); 114 | Serial.println("Client Disconnected."); 115 | } 116 | } 117 | --------------------------------------------------------------------------------