Jump to content

Arduino and PHP


SkatefishDori

Recommended Posts

Hello thereĀ  ;D

I try to interface arduino with php. My problem is when i click the button, my LED did not light on. The information that i entered in the form has been recorded in the phpmyadmin. I want both the LED light on and the information is save in phpmyadmin. how can i solved this LED problem.



<?php


// SPECIFY USB PORT TO USE
$usb_comPort = "COM3";

     switch($_POST)
	{
		case isset($_POST['submitOn']):
			exec("ECHO 1 > $usb_comPort"); // Turn On LED 1
			break;
		case isset($_POST['submitOff']):
			exec("ECHO 2 > $usb_comPort "); // Turn Off LED 1
			break;
		case isset($_POST['submitOn1']):
			exec("ECHO 3 > $usb_comPort"); // Turn On LED 2
			break;
		case isset($_POST['submitOff1']):
			exec("ECHO 4 > $usb_comPort"); // Turn Off LED 1
			break;
		case isset($_POST['submitOn2']):
			exec("ECHO 5 > $usb_comPort"); // Turn On LED 3
			break;
		case isset($_POST['submitOff2']):
			exec("ECHO 6 > $usb_comPort"); // Turn Off LED 1
			break;
		case isset($_POST['submitOn3']):
			exec("ECHO 7 > $usb_comPort"); // Turn On LED 4
			break;
		case isset($_POST['submitOff3']):
			exec("ECHO  8 > $usb_comPort"); // Turn Off LED 1
			break;
		case isset($_POST['allon']):
			exec("ECHO  1,3,5,7 > $usb_comPort"); // Turn ON ALL 4 LED Bulbs
			break;
		case isset($_POST['alloff']):
			exec("ECHO  2,4,6,8 > $usb_comPort"); // Turn OFF ALL 4 LED Bulbs
			break;

	}


?>	


</head>


<body>

<h1>Parking Layout</h1>

<form method="post" action="">
<label>First Name</label>
<input type="text" name="First_Name" />
<br />
<label>Last Name</label>
<input type="text" name="Last_Name" />
<br />
<label>Phone Number</label>
<input type="number_format" name="Phone_Number" />
<br />
<br />
<br />
<label>Date</label>
<input type="date" name="Date" />
<br />
<br />
<br />
<label>Time</label>
<input type="time" name="Time" />
<br />
<br />
<br />



	<form  method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" >
	
		<input type='submit' name='submitOn' value='Turn LED 1 ON'>
		<input type='submit' name='submitOff' value='Turn LED 1 OFF'>
		<br><br>
		<input type='submit'  name='submitOn1'  value='Turn LED 2 ON'>
		<input type='submit'  name='submitOff1' value='Turn LED 2 OFF'>
		<br><br>
		<input type='submit'  name='submitOn2'  value='Turn LED 3 ON'>
		<input type='submit'  name='submitOff2'  value='Turn LED 3 OFF'>
		<br><br>
		<input type='submit'  name='submitOn3'  value='Turn LED 4 ON'>
		<input type='submit'  name='submitOff3'  value='Turn LED 4 OFF'>


		<br><br>
		<input type='submit' name='allon' value='Turn ALL LEDs On'>
		<input type='submit' name='alloff' value='Turn ALL LEDs Off'>

	</form>
	

</body>

</html>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.