Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
projets:cctv_disco:start [2021/11/22 14:11] admin [Notes techniques et matériaux] |
projets:cctv_disco:start [2022/04/06 17:31] (Version actuelle) risbo [Photos et médias] |
||
---|---|---|---|
Ligne 20: | Ligne 20: | ||
===== Notes techniques et matériaux ===== | ===== Notes techniques et matériaux ===== | ||
- | |||
- | * Esp 32 | ||
- | * Camera shield esp 32 | ||
- | * esp8266 | ||
- | * led de couleur assez puissantes | ||
- | * booster 5V-12v | ||
- | * lecteur mp3 pour arduino + ampli + enceinte | ||
- | |||
* **ESP32 cam** [[https:// | * **ESP32 cam** [[https:// | ||
Ligne 38: | Ligne 30: | ||
* :!: **Led 4mm** [[https:// | * :!: **Led 4mm** [[https:// | ||
+ | * Jumper | ||
+ | * Breadboard | ||
+ | * Powerbank et peut être booster... | ||
+ | * Enceinte Bluetooth si besoin son fort | ||
Ligne 53: | Ligne 49: | ||
==== Code ==== | ==== Code ==== | ||
- | Pour l' | + | Code qui cree une pageweb |
+ | L'url de la page est donné en serie. (en l' | ||
<code c+> | <code c+> | ||
- | /********* | + | // MP3 lib |
- | Rui Santos | + | #include < |
- | | + | #include " |
- | *********/ | + | |
+ | #define MP3_RX 12//RX of Serial MP3 module connect to D7 of wemos | ||
+ | #define MP3_TX 13//TX to D8, wemos | ||
+ | MP3 mp3(MP3_RX, MP3_TX); | ||
+ | |||
+ | int8_t track = 0x01;//the first song in the TF card | ||
+ | int8_t track2 | ||
+ | int8_t volume = 0x1a;//0~0x1e (30 adjustable level) | ||
+ | |||
// Load Wi-Fi library | // Load Wi-Fi library | ||
#include < | #include < | ||
+ | |||
// Replace with your network credentials | // Replace with your network credentials | ||
const char* ssid = " | const char* ssid = " | ||
const char* password = " | const char* password = " | ||
+ | |||
// Set web server port number to 80 | // Set web server port number to 80 | ||
WiFiServer server(80); | WiFiServer server(80); | ||
+ | |||
// Variable to store the HTTP request | // Variable to store the HTTP request | ||
String header; | String header; | ||
+ | |||
// Auxiliar variables to store the current output state | // Auxiliar variables to store the current output state | ||
String output5State = " | String output5State = " | ||
String output4State = " | String output4State = " | ||
+ | |||
// Assign output variables to GPIO pins | // Assign output variables to GPIO pins | ||
const int output5 = 5; | const int output5 = 5; | ||
const int output4 = 4; | const int output4 = 4; | ||
+ | |||
// Current time | // Current time | ||
unsigned long currentTime = millis(); | unsigned long currentTime = millis(); | ||
Ligne 88: | Ligne 94: | ||
// Define timeout time in milliseconds (example: 2000ms = 2s) | // Define timeout time in milliseconds (example: 2000ms = 2s) | ||
const long timeoutTime = 2000; | const long timeoutTime = 2000; | ||
+ | |||
void setup() { | void setup() { | ||
Serial.begin(115200); | Serial.begin(115200); | ||
Ligne 97: | Ligne 103: | ||
digitalWrite(output5, | digitalWrite(output5, | ||
digitalWrite(output4, | digitalWrite(output4, | ||
+ | |||
// Connect to Wi-Fi network with SSID and password | // Connect to Wi-Fi network with SSID and password | ||
Serial.print(" | Serial.print(" | ||
Ligne 113: | Ligne 119: | ||
server.begin(); | server.begin(); | ||
} | } | ||
+ | |||
void loop(){ | void loop(){ | ||
WiFiClient client = server.available(); | WiFiClient client = server.available(); | ||
+ | |||
if (client) { // If a new client connects, | if (client) { // If a new client connects, | ||
Serial.println(" | Serial.println(" | ||
Ligne 138: | Ligne 144: | ||
client.println(" | client.println(" | ||
client.println(); | client.println(); | ||
- | | + | |
// turns the GPIOs on and off | // turns the GPIOs on and off | ||
if (header.indexOf(" | if (header.indexOf(" | ||
Ligne 144: | Ligne 150: | ||
output5State = " | output5State = " | ||
digitalWrite(output5, | digitalWrite(output5, | ||
+ | mp3.playWithVolume(track2, | ||
+ | delay(50); | ||
+ | |||
+ | | ||
} else if (header.indexOf(" | } else if (header.indexOf(" | ||
Serial.println(" | Serial.println(" | ||
output5State = " | output5State = " | ||
digitalWrite(output5, | digitalWrite(output5, | ||
+ | mp3.stopPlay(); | ||
+ | delay(50); | ||
+ | |||
+ | | ||
} else if (header.indexOf(" | } else if (header.indexOf(" | ||
Serial.println(" | Serial.println(" | ||
output4State = " | output4State = " | ||
+ | |||
+ | // | ||
digitalWrite(output4, | digitalWrite(output4, | ||
+ | mp3.playWithVolume(track, | ||
+ | delay(50); | ||
+ | |||
+ | | ||
} else if (header.indexOf(" | } else if (header.indexOf(" | ||
Serial.println(" | Serial.println(" | ||
output4State = " | output4State = " | ||
digitalWrite(output4, | digitalWrite(output4, | ||
+ | mp3.stopPlay(); | ||
+ | delay(50); | ||
} | } | ||
- | | + | |
// Display the HTML web page | // Display the HTML web page | ||
client.println("< | client.println("< | ||
Ligne 168: | Ligne 190: | ||
client.println(" | client.println(" | ||
client.println(" | client.println(" | ||
- | | + | |
// Web Page Heading | // Web Page Heading | ||
client.println("< | client.println("< | ||
- | | + | |
// Display current state, and ON/OFF buttons for GPIO 5 | // Display current state, and ON/OFF buttons for GPIO 5 | ||
client.println("< | client.println("< | ||
Ligne 180: | Ligne 202: | ||
client.println("< | client.println("< | ||
} | } | ||
- | + | ||
// Display current state, and ON/OFF buttons for GPIO 4 | // Display current state, and ON/OFF buttons for GPIO 4 | ||
client.println("< | client.println("< | ||
Ligne 190: | Ligne 212: | ||
} | } | ||
client.println("</ | client.println("</ | ||
- | | + | |
// The HTTP response ends with another blank line | // The HTTP response ends with another blank line | ||
client.println(); | client.println(); | ||
Ligne 211: | Ligne 233: | ||
} | } | ||
} | } | ||
- | |||
</ | </ | ||
- | ===== Photos et médias===== | + | {{: |
Code pour afficher les images du projet : | Code pour afficher les images du projet : | ||
{{gallery>?& | {{gallery>?& |