add defines, create simple sendButton function
This commit is contained in:
@@ -30,3 +30,5 @@
|
|||||||
*.exe
|
*.exe
|
||||||
*.out
|
*.out
|
||||||
*.app
|
*.app
|
||||||
|
|
||||||
|
secrets.h
|
||||||
@@ -5,3 +5,10 @@ This is an arduino sketch to make an IR-remote control for easier title renaming
|
|||||||
- Add webserver
|
- Add webserver
|
||||||
- Add ir remote library
|
- Add ir remote library
|
||||||
- Add SD-Card support to load html and css
|
- 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"
|
||||||
|
```
|
||||||
@@ -1,42 +1,38 @@
|
|||||||
/*
|
/*
|
||||||
WiFi Web Server LED Blink
|
|
||||||
|
|
||||||
A simple web server that lets you blink an LED via the web.
|
WebServer to use as replacement for Sony RM-D27M to control Sony MiniDisc decks.
|
||||||
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
|
Based on the the following sketches:
|
||||||
to turn on and off the LED on pin 5.
|
- SimpleWifiServer example
|
||||||
|
- SD_Test
|
||||||
|
- IRremote/SendDemo
|
||||||
|
|
||||||
|
|
||||||
If the IP address of your shield is yourAddress:
|
If the IP address of your shield is yourAddress:
|
||||||
http://yourAddress/H turns the LED on
|
http://yourAddress/H turns the LED on
|
||||||
http://yourAddress/L turns it off
|
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:
|
Circuit:
|
||||||
* LED attached to pin 13
|
* LED attached to pin 13 (optional)
|
||||||
* IR Transmitter attached to pin 4
|
* IR Transmitter attached to pin 4
|
||||||
|
* SD-Module to load HTML and CSS from SD-card
|
||||||
|
|
||||||
created for arduino 25 Nov 2012
|
developed for the ESP32vn IoT Uni board 2024
|
||||||
by Tom Igoe
|
|
||||||
|
|
||||||
ported for sparkfun esp32
|
|
||||||
31.01.2017 by Jan Hendrik Berlin
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include <IRremote.hpp>
|
#include <IRremote.hpp>
|
||||||
|
#include "secrets.h"
|
||||||
const char* ssid = "FritzBox-7590-NB";
|
#include "defines.h"
|
||||||
const char* password = "60762265561727730801";
|
|
||||||
|
|
||||||
WiFiServer server(80);
|
WiFiServer server(80);
|
||||||
|
|
||||||
void setup()
|
void setup() {
|
||||||
{
|
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
pinMode(13, OUTPUT); // set the LED pin mode
|
pinMode(LED_PIN, OUTPUT); // set the LED pin mode
|
||||||
|
|
||||||
delay(10);
|
delay(10);
|
||||||
|
|
||||||
@@ -45,22 +41,19 @@ void setup()
|
|||||||
Serial.println();
|
Serial.println();
|
||||||
Serial.println();
|
Serial.println();
|
||||||
Serial.print("Connecting to ");
|
Serial.print("Connecting to ");
|
||||||
Serial.println(ssid);
|
Serial.println(SSID);
|
||||||
|
|
||||||
WiFi.begin(ssid, password);
|
WiFi.begin(SSID, PASSWORD);
|
||||||
|
|
||||||
while (WiFi.status() != WL_CONNECTED) {
|
while (WiFi.status() != WL_CONNECTED) {
|
||||||
delay(500);
|
delay(500);
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Here the macro IR_SEND_PIN is not defined or undefined above with #undef IR_SEND_PIN
|
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
|
||||||
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.println();
|
||||||
Serial.print(F("Send IR signals at pin "));
|
Serial.print(F("Send IR signals at pin "));
|
||||||
Serial.println(tSendPin);
|
Serial.println(IR_SEND_PIN);
|
||||||
|
|
||||||
Serial.println();
|
Serial.println();
|
||||||
Serial.println("WiFi connected.");
|
Serial.println("WiFi connected.");
|
||||||
@@ -68,7 +61,6 @@ void setup()
|
|||||||
Serial.println(WiFi.localIP());
|
Serial.println(WiFi.localIP());
|
||||||
|
|
||||||
server.begin();
|
server.begin();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -99,7 +91,7 @@ void loop(){
|
|||||||
client.print("Click <a href=\"/L\">here</a> to turn the LED on pin 13 off.<br>");
|
client.print("Click <a href=\"/L\">here</a> to turn the LED on pin 13 off.<br>");
|
||||||
client.print("<a href=\"/play\">play</a><br>");
|
client.print("<a href=\"/play\">play</a><br>");
|
||||||
client.print("<form action=\"/api/control-deck\" method=\"post\"><button name=\"control\" type=\"submit\" value=\"play\">play</button></form><br>");
|
client.print("<form action=\"/api/control-deck\" method=\"post\"><button name=\"control\" type=\"submit\" value=\"play\">play</button></form><br>");
|
||||||
client.print("<form action=\"/api/control-deck\" method=\"get\"><input name=\"textinput\" type=\"text\" /></form><br>");
|
client.print("<form action=\"/api/control-deck\" method=\"get\"><input name=\"textinput\" type=\"text\" /><button type=\"submit\">send</button></form><br>");
|
||||||
|
|
||||||
// The HTTP response ends with another blank line:
|
// The HTTP response ends with another blank line:
|
||||||
client.println();
|
client.println();
|
||||||
@@ -114,15 +106,16 @@ void loop(){
|
|||||||
|
|
||||||
// Check to see if the client request was "GET /H" or "GET /L":
|
// Check to see if the client request was "GET /H" or "GET /L":
|
||||||
if (currentLine.endsWith("GET /H")) {
|
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")) {
|
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")) {
|
if (currentLine.endsWith("GET /play")) {
|
||||||
Serial.println("MD play");
|
//Serial.println("MD play");
|
||||||
Serial.flush();
|
//Serial.flush();
|
||||||
IrSender.sendSony(0xF, 0x2A, 2, 12);
|
//IrSender.sendSony(0xF, PLAY, 2, 12);
|
||||||
|
sendButton(PLAY);
|
||||||
}
|
}
|
||||||
if (currentLine.endsWith("POST /api/control-deck")) {
|
if (currentLine.endsWith("POST /api/control-deck")) {
|
||||||
|
|
||||||
@@ -137,3 +130,10 @@ void loop(){
|
|||||||
Serial.println("Client Disconnected.");
|
Serial.println("Client Disconnected.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sendButton(int command)
|
||||||
|
{
|
||||||
|
Serial.println(command);
|
||||||
|
Serial.flush();
|
||||||
|
IrSender.sendSony(0xF, command, 2, 12);
|
||||||
|
}
|
||||||
|
|||||||
@@ -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 EJECT 0x69E
|
||||||
#define POWER 0xA9E
|
//#define POWER 0xA9E
|
||||||
#define DISPLAY 0x19E
|
#define DISPLAY 0x19E
|
||||||
#define SCROLL 0x99E
|
#define SCROLL 0x99E
|
||||||
#define CONTINUE 0xB9E
|
#define CONTINUE 0xB9E
|
||||||
@@ -41,11 +54,11 @@
|
|||||||
#define CHAR 0x6DE
|
#define CHAR 0x6DE
|
||||||
#define NUM 0xEDE
|
#define NUM 0xEDE
|
||||||
#define CLEAR 0xF1E
|
#define CLEAR 0xF1E
|
||||||
#define PLAY 0x55E
|
// #define PLAY 0x55E
|
||||||
#define PAUSE 0x95E
|
// #define PAUSE 0x95E
|
||||||
#define STOP 0x15E
|
// #define STOP 0x15E
|
||||||
#define AMSPREV 0x05E
|
// #define AMSPREV 0x05E
|
||||||
#define AMSNEXT 0x85E
|
// #define AMSNEXT 0x85E
|
||||||
#define RECORD 0xB5E
|
#define RECORD 0xB5E
|
||||||
#define REWIND 0xD5E
|
#define REWIND 0xD5E
|
||||||
#define FASTFORWARD 0x35E
|
#define FASTFORWARD 0x35E
|
||||||
|
|||||||
Reference in New Issue
Block a user