mirror of
https://github.com/Lapikud/arduino_remote.git
synced 2026-03-23 13:24:20 +00:00
Lisan oma koodi
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -102,3 +102,4 @@ venv.bak/
|
|||||||
|
|
||||||
# mypy
|
# mypy
|
||||||
.mypy_cache/
|
.mypy_cache/
|
||||||
|
.idea/
|
||||||
43
Hanna/arduino/main.py
Normal file
43
Hanna/arduino/main.py
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
import serial
|
||||||
|
from flask import Flask, render_template, redirect, request
|
||||||
|
|
||||||
|
|
||||||
|
def send(cmd):
|
||||||
|
ser = serial.Serial()
|
||||||
|
ser.rts = False
|
||||||
|
ser.dtr = False
|
||||||
|
ser.port = "COM3"
|
||||||
|
ser.open()
|
||||||
|
ser.write(cmd)
|
||||||
|
ser.close()
|
||||||
|
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/')
|
||||||
|
def hello_world():
|
||||||
|
return render_template("index.html")
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/red')
|
||||||
|
def red():
|
||||||
|
send(b"r")
|
||||||
|
return redirect('/')
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/blue')
|
||||||
|
def blue():
|
||||||
|
send(b"t")
|
||||||
|
return redirect('/')
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/led', methods=["POST"])
|
||||||
|
def led():
|
||||||
|
cmd = request.form["cmd"]
|
||||||
|
send(cmd.encode())
|
||||||
|
return redirect("/")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run(host="0.0.0.0")
|
||||||
21
Hanna/arduino/templates/index.html
Normal file
21
Hanna/arduino/templates/index.html
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>:D</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>
|
||||||
|
hi!
|
||||||
|
<a href="/red">red</a>
|
||||||
|
<a href="/blue">blue</a><br>
|
||||||
|
<form action = "/led" method = "POST">
|
||||||
|
<!--input type="text" name="cmd" --><br>
|
||||||
|
<input type="submit" value="send">
|
||||||
|
<input type="submit" value="+" name="cmd">
|
||||||
|
<input type="submit" value="-" name="cmd">
|
||||||
|
</form>
|
||||||
|
</h1>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
28
Hanna/ir_test/ir_test.ino
Normal file
28
Hanna/ir_test/ir_test.ino
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#include <IRLibAll.h>
|
||||||
|
|
||||||
|
IRsend mySender;
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(9600);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
char c = Serial.read();
|
||||||
|
if (c != -1) {
|
||||||
|
switch (c) {
|
||||||
|
case '+':
|
||||||
|
mySender.send(NEC,0x4BB640BF, 32);
|
||||||
|
break;
|
||||||
|
case '-':
|
||||||
|
mySender.send(NEC,0x4BB6C03F, 32);
|
||||||
|
break;
|
||||||
|
case 'r':
|
||||||
|
mySender.send(NEC,0xFF906F, 32);
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
mySender.send(NEC,0xFF50AF, 32);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Serial.write(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user