This commit is contained in:
El-yazide MOHAMED 2025-06-07 20:55:18 +02:00
parent fe24e5aa23
commit 10e8782798
2 changed files with 20 additions and 1 deletions

View File

@ -20,7 +20,7 @@ let currentRotation = 0; // rotation en degrés actuelle du vinyle
// 3. Connexion Socket.io
/* const socket = io();
const socket = io();
socket.on('position', (position) => {
const now = Date.now();
@ -66,6 +66,7 @@ socket.on('position', (position) => {
}, 300);
});
/*
// 4. Fonctions
function togglePlay() {

View File

@ -80,6 +80,24 @@ const app = express();
const server = http.createServer(app);
const io = socketIo(server);
const SerialPort = require('serialport');
const ReadlineParser = require('@serialport/parser-readline');
const portName = "/dev/ttyUSB0"; // adapte selon ta config
const arduinoSerialPort = new SerialPort(portName, { baudRate: 115200 });
const parser = arduinoSerialPort.pipe(new ReadlineParser({ delimiter: '\n' }));
parser.on('data', (data) => {
console.log('Données reçues Arduino:', data.trim());
io.emit('position', data.trim()); // envoi à tous les clients
});
io.on('connection', (socket) => {
console.log('Client connecté');
// Ici tu peux gérer d'autres events socket si besoin
});
app.use(express.static('assets')); // dossier public pour fichiers front
let currentAudioProcess = null;