-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsendForm.php
23 lines (21 loc) · 858 Bytes
/
sendForm.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
//check the GET action var to see if an action is to be performed
//Load the serial port class
require("php_serial.class.php");
$serial = new phpSerial();
$serial->deviceSet("/dev/cu.usbmodem1421");
$serial->confBaudRate(9600);
$serial->deviceOpen();
$pin = $_GET['pin'];
$value = $_GET['value'];
error_log($value);
$direction = $_GET['direction'];
// send values to arduino
//error_log('get' . $pin . ' ' . $value . ' ' . $direction);
//$serial->sendMessage($pin . '?value=' . $value . '?direction=' . $direction);
$serial->sendMessage('A'.$pin .'B'.$value.'C'.$direction);
//$serial->sendMessage($value);
//Issue the appropriate command according to the Arduino source code 0=Green On, 1=Green Off, 2=Red On, 3=Red Off.
// close serial connection
$serial->deviceClose();
?>