Stap 5: Wijzig de code...
Voer de volgende opdrachten voor het openen van uw huidige code van de webpagina:
sudo nano /var/www/index.php
De nieuwe onderdelen toevoegen zoals hieronder getoond of kopieer deze code naar de index.php bestand:
<?php if (isset($_POST['on'])) { exec("sudo killall python"); exec("sudo python /var/www/mystuff/ledON.py"); } else if (isset($_POST['off'])) { exec("sudo killall python"); exec("sudo python /var/www/mystuff/ledOFF.py"); } else if (isset($_POST['blink'])) { exec("sudo python /var/www/mystuff/ledBLINK.py"); } //New code starts here else if (isset($_POST['WhereTheRiverFlows']))//Your first song { exec("sudo omxplayer /home/pi/songs/'Where The River Flows.mp3'"); } else if (isset($_POST['StarWars']))//Your second song { exec("sudo omxplayer /home/pi/songs/'Star Wars.mp3'"); } else if (isset($_POST['BezubaanPhirSe'])//Your third song<br> { exec("sudo omxplayer /home/pi/songs/'Bezubaan Phir Se.mp3'"); } else if (isset($_POST['bell']))//A funny sound clip { exec("sudo omxplayer /home/pi/songs/'bell.mp3'"); } else if (isset($_POST['Presentation']))//Your video { exec("sudo omxplayer /home/pi/videos/Presentation.mp4"); } else if (isset($_POST['stop all']))//This is to stop all media { exec("sudo killall omxplayer.bin"); }//This command stops all media ?> <html> <style type="text/css"> //Button colour is now yellow and size has been changed #form{font: bold 30px/30px Georgia, serif;} button{background: rgba(255, 255, 0, 0.99); width: 250px; height: 180px;border: none;border: 3px solid black;border-radius:20px;} #container{margin0px; auto;width:80%;min-width:40%;} </style> <body> <div id="container"> <form id="form" method="post"> <center> <button name="bell"><h1>Bell</h1></button> <br><br> <button name="on"><h1>Led ON</h1></button> <button name="off"><h1>Led OFF</h1></button> <button name="blink"><h1>Led BLINK</h1></button> //This part is contains the new buttons <br><br> <button name="StarWars"><h1>Star Wars</h1></button>//Your first song button <button name="BezubaanPhirSe"><h1>Bezubaan Phir Se</h1></button>//Your second song button <button name="WhereTheRiverFlows"><h2>Where The River Flows</h2></button>//Your third song button <br><br> <button name="Presentation"><h1>Presentation</h1></button>//Your video button <br><br> <button name="stop all"><h1>Stop all media</h1></button>//The button to stop all media </center> </form> </div> </body> </html>