code ousmane
This commit is contained in:
parent
cfd66549ed
commit
13d92d1562
|
@ -13,3 +13,5 @@ platform = espressif32
|
||||||
board = esp32-devkitlipo
|
board = esp32-devkitlipo
|
||||||
framework = arduino
|
framework = arduino
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
|
lib_deps = esphome/ESP32-audioI2S@^2.0.7
|
||||||
|
|
||||||
|
|
81
src/main.cpp
81
src/main.cpp
|
@ -1,79 +1,16 @@
|
||||||
/*
|
#include <Arduino.h>
|
||||||
Simple Internet Radio Demo
|
|
||||||
esp32-i2s-simple-radio.ino
|
|
||||||
Simple ESP32 I2S radio
|
|
||||||
Uses MAX98357 I2S Amplifier Module
|
|
||||||
Uses ESP32-audioI2S Library - https://github.com/schreibfaul1/ESP32-audioI2S
|
|
||||||
|
|
||||||
DroneBot Workshop 2022
|
|
||||||
https://dronebotworkshop.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Include required libraries
|
|
||||||
#include "Arduino.h"
|
|
||||||
#include "WiFi.h"
|
|
||||||
#include "Audio.h"
|
|
||||||
|
|
||||||
// Define I2S connections
|
|
||||||
#define I2S_DOUT 22
|
|
||||||
#define I2S_BCLK 26
|
|
||||||
#define I2S_LRC 25
|
|
||||||
|
|
||||||
// Create audio object
|
|
||||||
Audio audio;
|
|
||||||
const int potPin = 33;
|
const int potPin = 33;
|
||||||
float potvalue=0.00;
|
//la valeur du potentiomètre
|
||||||
float volume;
|
|
||||||
|
|
||||||
|
int potvalue=0;
|
||||||
|
|
||||||
// Wifi Credentials
|
void setup() {
|
||||||
String ssid = "cohabit";
|
pinMode(potPin,INPUT);
|
||||||
String password = "lewifidecohabit";
|
Serial.begin(9600);
|
||||||
|
|
||||||
void setup()
|
|
||||||
{
|
|
||||||
|
|
||||||
// Start Serial Monitor
|
|
||||||
Serial.begin(115200);
|
|
||||||
|
|
||||||
// Setup WiFi in Station mode
|
|
||||||
WiFi.disconnect();
|
|
||||||
WiFi.mode(WIFI_STA);
|
|
||||||
WiFi.begin(ssid.c_str(), password.c_str());
|
|
||||||
|
|
||||||
while (WiFi.status() != WL_CONNECTED)
|
|
||||||
{
|
|
||||||
delay(500);
|
|
||||||
Serial.print(".");
|
|
||||||
}
|
}
|
||||||
|
void loop() {
|
||||||
|
|
||||||
// WiFi Connected, print IP to serial monitor
|
//mesure la valeur du potentiomtre
|
||||||
Serial.println("");
|
|
||||||
Serial.println("WiFi connected");
|
|
||||||
Serial.println("IP address: ");
|
|
||||||
Serial.println(WiFi.localIP());
|
|
||||||
Serial.println("");
|
|
||||||
Serial.print("connected");
|
|
||||||
|
|
||||||
// Connect MAX98357 I2S Amplifier Module
|
|
||||||
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
|
|
||||||
Serial.print("coucou");
|
|
||||||
|
|
||||||
// Set thevolume (0-100)
|
|
||||||
audio.setVolume(100);
|
|
||||||
Serial.println("toto");
|
|
||||||
audio.connecttohost("http://194.97.151.146/antenne");
|
|
||||||
Serial.println("connexion antenne");
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop()
|
|
||||||
|
|
||||||
{
|
|
||||||
//Run audio player
|
|
||||||
potvalue=analogRead (potPin);
|
potvalue=analogRead (potPin);
|
||||||
volume = potvalue / 40.95;
|
Serial.println (potvalue);}
|
||||||
int(volume);
|
|
||||||
//Serial.println("%d",volume);
|
|
||||||
audio.setVolume(volume);
|
|
||||||
audio.loop();
|
|
||||||
}
|
|
Loading…
Reference in a new issue