以太网盾:从网络将数据发送到Arduino的使用HTML表单 [英] Ethernet shield: sending data from web to arduino using html form

查看:1087
本文介绍了以太网盾:从网络将数据发送到Arduino的使用HTML表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用按钮已经完成设备的控制通过互联网。我用Arduino的乌诺+ SD卡+以太网盾。现在我想,这样可用于发送文本通过表单提交命令来控制同来修改它。

I have already completed the controlling of devices through internet using buttons. I used Arduino Uno+ SD CARD+ Ethernet shield. Now I want to modify it so that used can send text commands through form submission to control the same.

当我使用Arduino的乌诺内存为HTML code,但现在,当我使用HTML SD卡面临的问题,我可以做到这一点。期待的一样code模块。

I could do it when I was using the Arduino Uno Memory for HTML code but now facing problems when I am using SD Card for HTML. Expecting the code module for the same.

推荐答案

是的,这是可能的。但是,你需要使用一个网络接口。我已经做了使用PHP。
所以,你创建HTML和PHP页面,当你点击提交按钮,就会发出命令。它必须是这样的,在PHP中:

Yes, it's possible. But you'll need to use a web socket. I've done that using PHP. So, you'll create a page with html and php that, when you click on the submit button, will send the commands. It must be like that, in php:

<?php 
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);

socket_connect($sock,"ip number of arduino", 8080);

$messsage = '0';
if (isset($_POST['on'])){
    $msg='1';
}
if (isset($_POST['off'])){
    $msg='0';
}

socket_write($sock, $msg);
?>

所以,你只需要编写一个HTML发送当一个表单所需提交的POST方法。

So you just need to write a html to send the post method when a form be submited.

这篇关于以太网盾:从网络将数据发送到Arduino的使用HTML表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆