diff --git a/.gitignore b/.gitignore index 259148f..04ae9f5 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,5 @@ *.exe *.out *.app + +secrets.h \ No newline at end of file diff --git a/README.md b/README.md index 90aa4f9..f4fb913 100644 --- a/README.md +++ b/README.md @@ -5,3 +5,10 @@ This is an arduino sketch to make an IR-remote control for easier title renaming - Add webserver - Add ir remote library - Add SD-Card support to load html and css + +Store WiFi secrets in a secrets.h like this: + +``` +#define SSID "your-ssid" +#define PASSWORD "your-password" +``` \ No newline at end of file diff --git a/arduino-sony-minidisc-ir-remote.ino b/arduino-sony-minidisc-ir-remote.ino index 1159503..1b12005 100644 --- a/arduino-sony-minidisc-ir-remote.ino +++ b/arduino-sony-minidisc-ir-remote.ino @@ -1,89 +1,81 @@ /* - WiFi Web Server LED Blink - A simple web server that lets you blink an LED via the web. - This sketch will print the IP address of your WiFi Shield (once connected) - to the Serial monitor. From there, you can open that address in a web browser - to turn on and off the LED on pin 5. + WebServer to use as replacement for Sony RM-D27M to control Sony MiniDisc decks. + + Based on the the following sketches: + - SimpleWifiServer example + - SD_Test + - IRremote/SendDemo + If the IP address of your shield is yourAddress: http://yourAddress/H turns the LED on http://yourAddress/L turns it off - This example is written for a network using WPA2 encryption. For insecure - WEP or WPA, change the Wifi.begin() call and use Wifi.setMinSecurity() accordingly. + Circuit: - * LED attached to pin 13 + * LED attached to pin 13 (optional) * IR Transmitter attached to pin 4 + * SD-Module to load HTML and CSS from SD-card - created for arduino 25 Nov 2012 - by Tom Igoe - -ported for sparkfun esp32 -31.01.2017 by Jan Hendrik Berlin + developed for the ESP32vn IoT Uni board 2024 */ #include #include - -const char* ssid = "FritzBox-7590-NB"; -const char* password = "60762265561727730801"; +#include "secrets.h" +#include "defines.h" WiFiServer server(80); -void setup() -{ - Serial.begin(115200); - pinMode(13, OUTPUT); // set the LED pin mode +void setup() { + Serial.begin(115200); + pinMode(LED_PIN, OUTPUT); // set the LED pin mode - delay(10); + delay(10); - // We start by connecting to a WiFi network + // We start by connecting to a WiFi network - Serial.println(); - Serial.println(); - Serial.print("Connecting to "); - Serial.println(ssid); + Serial.println(); + Serial.println(); + Serial.print("Connecting to "); + Serial.println(SSID); - WiFi.begin(ssid, password); + WiFi.begin(SSID, PASSWORD); - while (WiFi.status() != WL_CONNECTED) { - delay(500); - Serial.print("."); - } + while (WiFi.status() != WL_CONNECTED) { + delay(500); + Serial.print("."); + } - // Here the macro IR_SEND_PIN is not defined or undefined above with #undef IR_SEND_PIN - uint8_t tSendPin = 4; - IrSender.begin(tSendPin, ENABLE_LED_FEEDBACK, USE_DEFAULT_FEEDBACK_LED_PIN); // Specify send pin and enable feedback LED at default feedback LED pin - // You can change send pin later with IrSender.setSendPin(); - Serial.println(); - Serial.print(F("Send IR signals at pin ")); - Serial.println(tSendPin); + IrSender.begin(IR_SEND_PIN, ENABLE_LED_FEEDBACK, USE_DEFAULT_FEEDBACK_LED_PIN); // Specify send pin and enable feedback LED at default feedback LED pin + Serial.println(); + Serial.print(F("Send IR signals at pin ")); + Serial.println(IR_SEND_PIN); - Serial.println(); - Serial.println("WiFi connected."); - Serial.println("IP address: "); - Serial.println(WiFi.localIP()); - - server.begin(); + Serial.println(); + Serial.println("WiFi connected."); + Serial.println("IP address: "); + Serial.println(WiFi.localIP()); + server.begin(); } -void loop(){ - WiFiClient client = server.available(); // listen for incoming clients +void loop() { + WiFiClient client = server.available(); // listen for incoming clients - if (client) { // if you get a client, - Serial.println("New Client."); // print a message out the serial port - String currentLine = ""; // make a String to hold incoming data from the client - while (client.connected()) { // loop while the client's connected - if (client.available()) { // if there's bytes to read from the client, - char c = client.read(); // read a byte, then - Serial.write(c); // print it out the serial monitor - if (c == '\n') { // if the byte is a newline character + if (client) { // if you get a client, + Serial.println("New Client."); // print a message out the serial port + String currentLine = ""; // make a String to hold incoming data from the client + while (client.connected()) { // loop while the client's connected + if (client.available()) { // if there's bytes to read from the client, + char c = client.read(); // read a byte, then + Serial.write(c); // print it out the serial monitor + if (c == '\n') { // if the byte is a newline character // if the current line is blank, you got two newline characters in a row. // that's the end of the client HTTP request, so send a response: @@ -99,13 +91,13 @@ void loop(){ client.print("Click here to turn the LED on pin 13 off.
"); client.print("play
"); client.print("

"); - client.print("

"); + client.print("

"); // The HTTP response ends with another blank line: client.println(); // break out of the while loop: break; - } else { // if you got a newline, then clear currentLine: + } else { // if you got a newline, then clear currentLine: currentLine = ""; } } else if (c != '\r') { // if you got anything else but a carriage return character, @@ -114,18 +106,19 @@ void loop(){ // Check to see if the client request was "GET /H" or "GET /L": if (currentLine.endsWith("GET /H")) { - digitalWrite(13, HIGH); // GET /H turns the LED on + digitalWrite(LED_PIN, HIGH); // GET /H turns the LED on } if (currentLine.endsWith("GET /L")) { - digitalWrite(13, LOW); // GET /L turns the LED off + digitalWrite(LED_PIN, LOW); // GET /L turns the LED off } if (currentLine.endsWith("GET /play")) { - Serial.println("MD play"); - Serial.flush(); - IrSender.sendSony(0xF, 0x2A, 2, 12); + //Serial.println("MD play"); + //Serial.flush(); + //IrSender.sendSony(0xF, PLAY, 2, 12); + sendButton(PLAY); } if (currentLine.endsWith("POST /api/control-deck")) { - + Serial.println("POST"); char c = client.read(); Serial.print(c); @@ -137,3 +130,10 @@ void loop(){ Serial.println("Client Disconnected."); } } + +void sendButton(int command) +{ + Serial.println(command); + Serial.flush(); + IrSender.sendSony(0xF, command, 2, 12); +} diff --git a/defines.h b/defines.h index 79cb0a6..bc0077a 100644 --- a/defines.h +++ b/defines.h @@ -1,5 +1,18 @@ +// Pin definitions +#define IR_SEND_PIN 4 +#define LED_PIN 13 + +// IR commands (Sony 12bit) +#define POWER 0x15 +#define PLAY 0x2A +#define PAUSE 0x29 +#define STOP 0x28 +#define PREV 0x20 //geraten +#define NEXT 0x21 + +//old commands #define EJECT 0x69E -#define POWER 0xA9E +//#define POWER 0xA9E #define DISPLAY 0x19E #define SCROLL 0x99E #define CONTINUE 0xB9E @@ -41,11 +54,11 @@ #define CHAR 0x6DE #define NUM 0xEDE #define CLEAR 0xF1E -#define PLAY 0x55E -#define PAUSE 0x95E -#define STOP 0x15E -#define AMSPREV 0x05E -#define AMSNEXT 0x85E +// #define PLAY 0x55E +// #define PAUSE 0x95E +// #define STOP 0x15E +// #define AMSPREV 0x05E +// #define AMSNEXT 0x85E #define RECORD 0xB5E #define REWIND 0xD5E #define FASTFORWARD 0x35E