Programm mit zwei Tastern
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | #include “Arduino.h” #include “WiFi.h” #include “VS1053.h” #include “ESP32_VS1053_Stream.h” #include “LCDIC2.h” // 4‑zeiliges LCD LCDIC2 lcd(0x27, 20, 4); #include “OneButton.h” #define VS1053_CS 5 #define VS1053_DCS 16 #define VS1053_DREQ 4 // Pins Taster int TasterLautstaerke = 12; int TasterSender = 14; OneButton SenderWahl(TasterSender, true); OneButton LautstaerkeEinstellen(TasterLautstaerke, true); // Variablen Sender int SenderIndex = 0; int AnzahlSender = 0; int Lautstaerke = 80; int GesicherteLautstaerke = Lautstaerke; ESP32_VS1053_Stream stream; // WiFi-Daten char Router[] = “Router_SSID”; char Passwort[] = “xxxxxxxx”; const char* Sender[] = { “http://wdr-1live-live.icecast.wdr.de/wdr/1live/live/mp3/128/stream.mp3”, // 1Live “http://wdr-wdr2-bergischesland.icecast.wdr.de/wdr/wdr2/bergischesland/mp3/128/stream.mp3”, // WDR2 “http://wdr-wdr4-live.icecast.wdr.de/wdr/wdr4/live/mp3/128/stream.mp3”, // WDR4 “http://liveradio.swr.de/sw282p3/swr3/play.mp3”, // SWR3 “http://dispatcher.rndfnk.com/swr/swr4/ko/mp3/128/stream.mp3”, // SWR4 “http://avw.mdr.de/streams/284321–1_mp3_high.m3u”, // MDR JUMP Rock channel “http://dispatcher.rndfnk.com/hr/hr1/rheinmain/high”, // HR1 “http://www.ndr.de/resources/metadaten/audio/m3u/ndr2_hh.m3u”, // NDR Hamburg “http://dispatcher.rndfnk.com/rbb/rbb888/live/mp3/mid”, // RBB 88,8 “http://liveradio.sr.de/sr/sr3/mp3/128/stream.mp3”, // SR 3 “http://icecast.ndr.de/ndr/njoy/live/mp3/128/stream.mp3”, // N‑Joy “http://st01.sslstream.dlf.de/dlf/01/128/mp3/stream.mp3?aggregator=web”, // Deutschlandfunk “http://stream.lokalradio.nrw/444z6rq”, // Radio Berg “http://orf-live.ors-shoutcast.at/oe3-q2a”, // Ö3 “http://antennebrandenburg.de/livemp3”, // Antenne Brandenburg “http://stream.antenne.de/antenne/stream/mp3”, // Antenne Bayern live “http://stream.antenne.de/antenne-bayern-70er-rock/stream/mp3”, // Antenne Bayern 70er Rock “http://stream.antenne.de/classic-rock-live/stream/mp3”, // Antenne Bayern Classic Rock “http://stream.antenne.de/antenne-bayern-80er-rock/stream/mp3”, // Antenne Bayern 80er Rock “http://classicrock.radioarabella.de/arabella-classicrock.mp3”, // Radio Arabella “http://www.charivari.de/webradio/r8082.m3u”, // Radio Charivari München }; const char *Beschreibung[] { “1Live”, “WDR 2”, “WDR 4”, “SWR 3”, “SWR 4”, “MDR JUMP”, “HR 1”, “NDR 2”, “RBB 88,8”, “SR 3”, “N‑Joy”, “Deutschlandfunk”,“Radio Berg”, “\xEF 3”, “Antenne Brandenburg”, “Antenne Bayern live”, “Antenme Bayern 70er”, “Antenne Bayern Rock”, “Antenne Bayern 80er”, “Radio Arabella”, “Radio Charivari” }; void setup() { Serial.begin(9600); // LCD starten lcd.begin(); // Cursor “verstecken” lcd.setCursor(false); /* Aktionen dem Modus der Tasters zuordnen setPressTicks(500); setClickTicks(200); setDebounceTicks(50); */ SenderWahl.attachClick(SenderVor); SenderWahl.attachDoubleClick(SenderZurueck); SenderWahl.attachLongPressStop(ErsterSender); LautstaerkeEinstellen.attachClick(Leiser); LautstaerkeEinstellen.attachDoubleClick(Lauter); LautstaerkeEinstellen.attachLongPressStop(TonAus); // pinModes definieren pinMode(TasterSender, INPUT_PULLUP); pinMode(TasterLautstaerke, INPUT_PULLUP); // auf Seriellen Monitor warten while (!Serial) { delay(10); } // WiFi starten WiFi.mode(WIFI_STA); WiFi.begin(Router, Passwort); Serial.println(“————————”); while (WiFi.status() != WL_CONNECTED) { delay(200); Serial.print(“.”); } Serial.println(); Serial.print(“Verbunden mit ”); Serial.println(WiFi.SSID()); Serial.print(“IP über DHCP: ”); Serial.println(WiFi.localIP()); // Start SPI bus SPI.setHwCs(true); SPI.begin(); // Decoder starten if (!stream.startDecoder(VS1053_CS, VS1053_DCS, VS1053_DREQ) || !stream.isChipConnected()) { Serial.println(“Decoder konnte nicht gestartet werden ..”); Serial.println(“Programm angehalten!”); while (1); } Serial.println(“MP3-Decoder gestartet …”); // Sender verbinden stream.connecttohost(Sender[SenderIndex]); // wenn der Stream nicht mehr läuft … if (!stream.isRunning()) { Serial.println(“Radio wird neu gestartet …”); stream.stopSong(); stream.connecttohost(Sender[SenderIndex]); } Serial.print(“Codec: ”); Serial.println(stream.currentCodec()); Serial.print(“Bitrate: ”); Serial.print(stream.bitrate()); Serial.println(“ kbps”); stream.setVolume(Lautstaerke); // Anzahl der Sender im Array feststellen AnzahlSender = sizeof(Sender) / sizeof(Sender[0]); Serial.println(“Anzahl der Sender:” + String(AnzahlSender)); lcd.clear(); lcd.setCursor(0, 0); lcd.print(Beschreibung[SenderIndex]); lcd.setCursor(0, 1); lcd.print(“Lautst\xe1rke: ” + String(Lautstaerke) + ” ”); } void loop() { SenderWahl.tick(); delay(10); LautstaerkeEinstellen.tick(); delay(10); // wenn Stream gestoppt -> neu verbinden if (!stream.isRunning()) { // stream.stopSong(); stream.connecttohost(Sender[SenderIndex]); } // Stream abspielen stream.loop(); delay(5); } // Sender im Seriellen Monitor anzeigen void audio_showstation(const char* info) { Serial.printf(“Station: %s\n”, info); } // Titel anzeigen void audio_showstreamtitle(const char* info) { String Titel = String(info); Titel.replace(“ — “, ” ”); Titel.replace(“ / “, ” ”); Titel.replace(“ von “, ” ”); if (Titel.length() > 20) Titel = Titel.substring(0, 20); lcd.setCursor(0,2); lcd.print(Titel); Serial.printf(“Titel: %s\n”, info); } void audio_eof_stream(const char* info) { Serial.printf(“Ende: %s\n”, info); } void SenderVor() { // wenn der letzte Sender -> zurück auf 0 if (SenderIndex >= AnzahlSender - 1) SenderIndex = 0; else SenderIndex++; Serial.println(SenderIndex); stream.stopSong(); stream.connecttohost(Sender[SenderIndex]); // Sender/Lautstärke auf dem LCD anzeigen lcd.clear(); lcd.setCursor(0, 0); lcd.print(Beschreibung[SenderIndex]); lcd.setCursor(0, 1); lcd.print(“Lautst\xe1rke: ” + String(Lautstaerke) + ” ”); } void SenderZurueck() { // wenn der letzte Sender -> zurück auf 0 if (SenderIndex == 0) SenderIndex = AnzahlSender - 1; else SenderIndex–; Serial.println(SenderIndex); stream.stopSong(); stream.connecttohost(Sender[SenderIndex]); // Sender/Lautstärke auf dem LCD anzeigen lcd.clear(); lcd.setCursor(0, 0); lcd.print(Beschreibung[SenderIndex]); lcd.setCursor(0, 1); lcd.print(“Lautst\xe1rke: ” + String(Lautstaerke) + ” ”); } void Leiser() { if (Lautstaerke > 5) Lautstaerke -= 5; // if (Lautstaerke == 0) Lautstaerke += 5; GesicherteLautstaerke = Lautstaerke; stream.setVolume(Lautstaerke); Serial.println(“Lautstärke: ” + String(Lautstaerke)); lcd.setCursor(0, 1); lcd.print(“Lautst\xe1rke: ” + String(Lautstaerke) + ” ”); } void Lauter() { if (Lautstaerke < 95) Lautstaerke += 5; GesicherteLautstaerke = Lautstaerke; stream.setVolume(Lautstaerke); Serial.println(“Lautstärke: ” + String(Lautstaerke)); lcd.setCursor(0, 1); lcd.print(“Lautst\xe1rke: ” + String(Lautstaerke) + ” ”); } void TonAus() { if (Lautstaerke == 0) { stream.setVolume(GesicherteLautstaerke); lcd.setCursor(0, 1); lcd.print(“Ton ein ”); Lautstaerke = GesicherteLautstaerke; } else { Lautstaerke = 0; stream.setVolume(Lautstaerke); Serial.println(“Lautstärke: ” + String(Lautstaerke)); lcd.setCursor(0, 1); lcd.print(“Ton aus ”); } } void ErsterSender() { SenderIndex = 0; Serial.println(SenderIndex); stream.stopSong(); stream.connecttohost(Sender[SenderIndex]); // Sender/Lautstärke auf dem LCD anzeigen lcd.clear(); lcd.setCursor(0, 0); lcd.print(Beschreibung[SenderIndex]); lcd.setCursor(0, 1); lcd.print(“Lautst\xe1rke: ” + String(Lautstaerke) + ” ”); } |
Programm mit drei Tastern

lauter — leiser — Senderwahl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | #include “Arduino.h” #include “WiFi.h” #include “VS1053.h” #include “ESP32_VS1053_Stream.h” #include “LCDIC2.h” // 4‑zeiliges LCD LCDIC2 lcd(0x27, 20, 4); // Bibliothek Bounce einbinden #include “Bounce2.h” // Bounce starten Bounce SenderGedrueckt = Bounce(); Bounce LauterGedrueckt = Bounce(); Bounce LeiserGedrueckt = Bounce(); #define VS1053_CS 5 #define VS1053_DCS 16 #define VS1053_DREQ 4 // Pins Taster int TasterLeiser = 12; int TasterLauter = 13; int TasterSender = 14; // Variablen Sender int SenderIndex = 0; int AnzahlSender = 0; int Lautstaerke = 80; ESP32_VS1053_Stream stream; // WiFi-Daten char Router[] = “Router_SSID”; char Passwort[] = “xxxxxxxx”; const char* Sender[] = { “http://wdr-1live-live.icecast.wdr.de/wdr/1live/live/mp3/128/stream.mp3”, // 1Live “http://wdr-wdr2-bergischesland.icecast.wdr.de/wdr/wdr2/bergischesland/mp3/128/stream.mp3”, // WDR2 “http://wdr-wdr4-live.icecast.wdr.de/wdr/wdr4/live/mp3/128/stream.mp3”, // WDR4 “http://liveradio.swr.de/sw282p3/swr3/play.mp3”, // SWR3 “http://dispatcher.rndfnk.com/swr/swr4/ko/mp3/128/stream.mp3”, // SWR4 “http://avw.mdr.de/streams/284321–1_mp3_high.m3u”, // MDR JUMP Rock channel “http://dispatcher.rndfnk.com/hr/hr1/rheinmain/high”, // HR1 “http://www.ndr.de/resources/metadaten/audio/m3u/ndr2_hh.m3u”, // NDR Hamburg “http://dispatcher.rndfnk.com/rbb/rbb888/live/mp3/mid”, // RBB 88,8 “http://liveradio.sr.de/sr/sr3/mp3/128/stream.mp3”, // SR 3 “http://icecast.ndr.de/ndr/njoy/live/mp3/128/stream.mp3”, // N‑Joy “http://st01.sslstream.dlf.de/dlf/01/128/mp3/stream.mp3?aggregator=web”, // Deutschlandfunk “http://stream.lokalradio.nrw/444z6rq”, // Radio Berg “http://orf-live.ors-shoutcast.at/oe3-q2a”, // Ö3 “http://antennebrandenburg.de/livemp3”, // Antenne Brandenburg “http://stream.antenne.de/antenne/stream/mp3”, // Antenne Bayern live “http://stream.antenne.de/antenne-bayern-70er-rock/stream/mp3”, // Antenne Bayern 70er Rock “http://stream.antenne.de/classic-rock-live/stream/mp3”, // Antenne Bayern Classic Rock “http://stream.antenne.de/antenne-bayern-80er-rock/stream/mp3”, // Antenne Bayern 80er Rock “http://classicrock.radioarabella.de/arabella-classicrock.mp3”, // Radio Arabella “http://www.charivari.de/webradio/r8082.m3u”, // Radio Charivari München }; const char *Beschreibung[] { “1Live”, “WDR 2”, “WDR 4”, “SWR 3”, “SWR 4”, “MDR JUMP”, “HR 1”, “NDR 2”, “RBB 88,8”, “SR 3”, “N‑Joy”, “Deutschlandfunk”,“Radio Berg”, “\xEF 3”, “Antenne Brandenburg”, “Antenne Bayern live”, “Antenme Bayern 70er”, “Antenne Bayern Rock”, “Antenne Bayern 80er”, “Radio Arabella”, “Radio Charivari” }; void setup() { Serial.begin(9600); // LCD starten lcd.begin(); // Cursor “verstecken” lcd.setCursor(false); // Bounce den Tastern zuordnen SenderGedrueckt.attach(TasterSender, INPUT_PULLUP); SenderGedrueckt.interval(20); LeiserGedrueckt.attach(TasterLeiser, INPUT_PULLUP); LeiserGedrueckt.interval(20); LauterGedrueckt.attach(TasterLauter, INPUT_PULLUP); LauterGedrueckt.interval(20); // pinModes definieren pinMode(TasterSender, INPUT_PULLUP); pinMode(TasterLeiser, INPUT_PULLUP); pinMode(TasterLauter, INPUT_PULLUP); // auf Seriellen Monitor warten while (!Serial) { delay(10); } // WiFi starten WiFi.mode(WIFI_STA); WiFi.begin(Router, Passwort); Serial.println(“————————”); while (WiFi.status() != WL_CONNECTED) { delay(200); Serial.print(“.”); } Serial.println(); Serial.print(“Verbunden mit ”); Serial.println(WiFi.SSID()); Serial.print(“IP über DHCP: ”); Serial.println(WiFi.localIP()); // Start SPI bus SPI.setHwCs(true); SPI.begin(); // Decoder starten if (!stream.startDecoder(VS1053_CS, VS1053_DCS, VS1053_DREQ) || !stream.isChipConnected()) { Serial.println(“Decoder konnte nicht gestartet werden ..”); Serial.println(“Programm angehalten!”); while (1); } Serial.println(“MP3-Decoder gestartet …”); // Sender verbinden stream.connecttohost(Sender[SenderIndex]); // wenn der Stream nicht mehr läuft … if (!stream.isRunning()) { Serial.println(“Radio wird neu gestartet …”); stream.stopSong(); stream.connecttohost(Sender[SenderIndex]); } Serial.print(“Codec: ”); Serial.println(stream.currentCodec()); Serial.print(“Bitrate: ”); Serial.print(stream.bitrate()); Serial.println(“ kbps”); stream.setVolume(Lautstaerke); // Anzahl der Sender feststellen und anzeigen AnzahlSender = sizeof(Sender) / sizeof(Sender[0]); Serial.println(“Anzahl der Sender: ” + String(AnzahlSender)); lcd.clear(); lcd.setCursor(0, 0); lcd.print(Beschreibung[SenderIndex]); lcd.setCursor(0, 1); lcd.print(“Lautst\xe1rke: ” + String(Lautstaerke) + ” ”); } void loop() { // Taster abfragen if (LeiserGedrueckt.update()) { if (LeiserGedrueckt.fell()) { if (Lautstaerke > 5) Lautstaerke -= 5; stream.setVolume(Lautstaerke); Serial.println(“Lautstärke: ” + String(Lautstaerke)); lcd.setCursor(0, 1); lcd.print(“Lautst\xe1rke: ” + String(Lautstaerke) + ” ”); } } if (LauterGedrueckt.update()) { if (LauterGedrueckt.fell()) { if (Lautstaerke < 95) Lautstaerke += 5; stream.setVolume(Lautstaerke); Serial.println(“Lautstärke: ” + String(Lautstaerke)); lcd.setCursor(0, 1); lcd.print(“Lautst\xe1rke: ” + String(Lautstaerke) + ” ”); } } if (SenderGedrueckt.update()) { if (SenderGedrueckt.fell()) { if (SenderIndex > 3) SenderIndex = 0; else SenderIndex++; Serial.println(SenderIndex); stream.stopSong(); stream.connecttohost(Sender[SenderIndex]); if (!stream.isRunning()) { stream.stopSong(); stream.connecttohost(Sender[SenderIndex]); } lcd.clear(); lcd.setCursor(0, 0); lcd.print(Beschreibung[SenderIndex]); lcd.setCursor(0, 1); lcd.print(“Lautst\xe1rke: ” + String(Lautstaerke) + ” ”); } // Codec/bitrate anzeigen Serial.print(“Codec: ”); Serial.println(stream.currentCodec()); Serial.print(“Bitrate: ”); Serial.print(stream.bitrate()); Serial.println(“ kbps”); } // wenn Stream gestoppt -> neu verbinden if (!stream.isRunning()) { stream.stopSong(); stream.connecttohost(Sender[SenderIndex]); } // Stream abspielen stream.loop(); delay(5); } void audio_showstation(const char* info) { Serial.printf(“Station: %s\n”, info); } void audio_showstreamtitle(const char* info) { Serial.printf(“Stream title: %s\n”, info); } void audio_eof_stream(const char* info) { Serial.printf(“End of stream: %s\n”, info); } |
Programm mit Fernbedienung
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | #include “Arduino.h” #include “WiFi.h” #include “VS1053.h” #include “ESP32_VS1053_Stream.h” #include “LCDIC2.h” #include “IRremote.hpp” int EmpfaengerPin = 13; // 4‑zeiliges LCD LCDIC2 lcd(0x27, 20, 4); // Pins des VS1053 #define VS1053_CS 5 #define VS1053_DCS 16 #define VS1053_DREQ 4 // Variablen Sender int SenderIndex = 0; int AnzahlSender = 0; int Lautstaerke = 80; int GesicherteLautstaerke = Lautstaerke; ESP32_VS1053_Stream stream; // WiFi-Daten char Router[] = “Router_SSID”; char Passwort[] = “xxxxxxxx”; const char* Sender[] = { “http://wdr-1live-live.icecast.wdr.de/wdr/1live/live/mp3/128/stream.mp3”, // 1Live “http://wdr-wdr2-bergischesland.icecast.wdr.de/wdr/wdr2/bergischesland/mp3/128/stream.mp3”, // WDR2 “http://wdr-wdr4-live.icecast.wdr.de/wdr/wdr4/live/mp3/128/stream.mp3”, // WDR4 “http://liveradio.swr.de/sw282p3/swr3/play.mp3”, // SWR3 “http://dispatcher.rndfnk.com/swr/swr4/ko/mp3/128/stream.mp3”, // SWR4 “http://avw.mdr.de/streams/284321–1_mp3_high.m3u”, // MDR JUMP Rock channel “http://dispatcher.rndfnk.com/hr/hr1/rheinmain/high”, // HR1 “http://www.ndr.de/resources/metadaten/audio/m3u/ndr2_hh.m3u”, // NDR Hamburg “http://dispatcher.rndfnk.com/rbb/rbb888/live/mp3/mid”, // RBB 88,8 “http://liveradio.sr.de/sr/sr3/mp3/128/stream.mp3”, // SR 3 “http://icecast.ndr.de/ndr/njoy/live/mp3/128/stream.mp3”, // N‑Joy “http://st01.sslstream.dlf.de/dlf/01/128/mp3/stream.mp3?aggregator=web”, // Deutschlandfunk “http://stream.lokalradio.nrw/444z6rq”, // Radio Berg “http://orf-live.ors-shoutcast.at/oe3-q2a”, // Ö3 “http://antennebrandenburg.de/livemp3”, // Antenne Brandenburg “http://stream.antenne.de/antenne/stream/mp3”, // Antenne Bayern live “http://stream.antenne.de/antenne-bayern-70er-rock/stream/mp3”, // Antenne Bayern 70er Rock “http://stream.antenne.de/classic-rock-live/stream/mp3”, // Antenne Bayern Classic Rock “http://stream.antenne.de/antenne-bayern-80er-rock/stream/mp3”, // Antenne Bayern 80er Rock “http://classicrock.radioarabella.de/arabella-classicrock.mp3”, // Radio Arabella “http://www.charivari.de/webradio/r8082.m3u”, // Radio Charivari München }; const char *Beschreibung[] { “1Live”, “WDR 2”, “WDR 4”, “SWR 3”, “SWR 4”, “MDR JUMP”, “HR 1”, “NDR 2”, “RBB 88,8”, “SR 3”, “N‑Joy”, “Deutschlandfunk”,“Radio Berg”, “\xEF 3”, “Antenne Brandenburg”, “Antenne Bayern live”, “Antenme Bayern 70er”, “Antenne Bayern Rock”, “Antenne Bayern 80er”, “Radio Arabella”, “Radio Charivari” }; void setup() { Serial.begin(9600); // LCD starten lcd.begin(); // Cursor “verstecken” lcd.setCursor(false); // Infrarot-Empfänger starten IrReceiver.begin(EmpfaengerPin); // auf Seriellen Monitor warten while (!Serial) { delay(10); } // WiFi starten WiFi.mode(WIFI_STA); WiFi.begin(Router, Passwort); Serial.println(“————————”); while (WiFi.status() != WL_CONNECTED) { delay(200); Serial.print(“.”); } Serial.println(); Serial.print(“Verbunden mit ”); Serial.println(WiFi.SSID()); Serial.print(“IP über DHCP: ”); Serial.println(WiFi.localIP()); // Start SPI bus SPI.setHwCs(true); SPI.begin(); // Decoder starten if (!stream.startDecoder(VS1053_CS, VS1053_DCS, VS1053_DREQ) || !stream.isChipConnected()) { Serial.println(“Decoder konnte nicht gestartet werden ..”); Serial.println(“Programm angehalten!”); while (1); } Serial.println(“MP3-Decoder gestartet …”); // Sender verbinden stream.connecttohost(Sender[SenderIndex]); // wenn der Stream nicht mehr läuft … if (!stream.isRunning()) { Serial.println(“Radio wird neu gestartet …”); stream.stopSong(); stream.connecttohost(Sender[SenderIndex]); } Serial.print(“Codec: ”); Serial.println(stream.currentCodec()); Serial.print(“Bitrate: ”); Serial.print(stream.bitrate()); Serial.println(“ kbps”); stream.setVolume(Lautstaerke); // Anzahl der Sender im Array feststellen AnzahlSender = sizeof(Sender) / sizeof(Sender[0]); Serial.println(“Anzahl der Sender:” + String(AnzahlSender)); lcd.clear(); lcd.setCursor(0, 0); lcd.print(Beschreibung[SenderIndex]); lcd.setCursor(0, 1); lcd.print(“Lautst\xe1rke: ” + String(Lautstaerke) + ” ”); } void loop() { // decode() -> Daten lesen if (IrReceiver.decode()) { // kurzes delay, damit nur ein Tastendruck gelesen wird delay(200); // resume -> nächsten Wert lesen IrReceiver.resume(); if (IrReceiver.decodedIRData.command > 0 && IrReceiver.decodedIRData.command < 95) { // Werte abfragen if (IrReceiver.decodedIRData.command == 22) ErsterSender(); if (IrReceiver.decodedIRData.command == 74) TonAus(); if (IrReceiver.decodedIRData.command == 68) SenderZurueck(); if (IrReceiver.decodedIRData.command == 67) SenderVor(); if (IrReceiver.decodedIRData.command == 70) Lauter(); if (IrReceiver.decodedIRData.command == 21) Leiser(); if (IrReceiver.decodedIRData.command == 64) Serial.println(“OK”); } } // wenn Stream gestoppt -> neu verbinden if (!stream.isRunning()) { // stream.stopSong(); stream.connecttohost(Sender[SenderIndex]); } // Stream abspielen stream.loop(); delay(5); } // Sender im Seriellen Monitor anzeigen void audio_showstation(const char* info) { Serial.printf(“Station: %s\n”, info); } // Titel anzeigen void audio_showstreamtitle(const char* info) { String Titel = String(info); Titel.replace(“ — “, ” ”); Titel.replace(“ / “, ” ”); Titel.replace(“ von “, ” ”); if (Titel.length() > 20) Titel = Titel.substring(0, 20); lcd.setCursor(0,2); lcd.print(Titel); Serial.printf(“Titel: %s\n”, info); } void audio_eof_stream(const char* info) { Serial.printf(“Ende: %s\n”, info); } void SenderVor() { // wenn der letzte Sender -> zurück auf 0 if (SenderIndex >= AnzahlSender - 1) SenderIndex = 0; else SenderIndex++; Serial.println(SenderIndex); stream.stopSong(); stream.connecttohost(Sender[SenderIndex]); // Sender/Lautstärke auf dem LCD anzeigen lcd.clear(); lcd.setCursor(0, 0); lcd.print(Beschreibung[SenderIndex]); lcd.setCursor(0, 1); lcd.print(“Lautst\xe1rke: ” + String(Lautstaerke) + ” ”); } void SenderZurueck() { // wenn der letzte Sender -> zurück auf 0 if (SenderIndex == 0) SenderIndex = AnzahlSender - 1; else SenderIndex–; Serial.println(SenderIndex); stream.stopSong(); stream.connecttohost(Sender[SenderIndex]); // Sender/Lautstärke auf dem LCD anzeigen lcd.clear(); lcd.setCursor(0, 0); lcd.print(Beschreibung[SenderIndex]); lcd.setCursor(0, 1); lcd.print(“Lautst\xe1rke: ” + String(Lautstaerke) + ” ”); } void Leiser() { if (Lautstaerke > 5) Lautstaerke -= 5; // if (Lautstaerke == 0) Lautstaerke += 5; GesicherteLautstaerke = Lautstaerke; stream.setVolume(Lautstaerke); Serial.println(“Lautstärke: ” + String(Lautstaerke)); lcd.setCursor(0, 1); lcd.print(“Lautst\xe1rke: ” + String(Lautstaerke) + ” ”); } void Lauter() { if (Lautstaerke < 95) Lautstaerke += 5; GesicherteLautstaerke = Lautstaerke; stream.setVolume(Lautstaerke); Serial.println(“Lautstärke: ” + String(Lautstaerke)); lcd.setCursor(0, 1); lcd.print(“Lautst\xe1rke: ” + String(Lautstaerke) + ” ”); } void TonAus() { if (Lautstaerke == 0) { stream.setVolume(GesicherteLautstaerke); lcd.setCursor(0, 1); lcd.print(“Ton ein ”); Lautstaerke = GesicherteLautstaerke; } else { Lautstaerke = 0; stream.setVolume(Lautstaerke); Serial.println(“Lautstärke: ” + String(Lautstaerke)); lcd.setCursor(0, 1); lcd.print(“Ton aus ”); } } void ErsterSender() { SenderIndex = 0; Serial.println(SenderIndex); stream.stopSong(); stream.connecttohost(Sender[SenderIndex]); // Sender/Lautstärke auf dem LCD anzeigen lcd.clear(); lcd.setCursor(0, 0); lcd.print(Beschreibung[SenderIndex]); lcd.setCursor(0, 1); lcd.print(“Lautst\xe1rke: ” + String(Lautstaerke) + ” ”); } |
Letzte Aktualisierung: