Pages: [1]   Go Down
Author Topic: lettura di un dato  (Read 725 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ho creato una pagina html che invia un parametro (intero) all'arduino contenente la scheda di rete async_labs. Il problema è ke nn riesco a leggere il dato dal programma arduino. La libreria usata è la WiShield. La pagina html funge da client mentre l'arduino fa da server.
Logged

BZ (I)
Offline Offline
Brattain Member
*****
Karma: 252
Posts: 21282
+39 349 2158303
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ciao DaNZeR
Come spedisci il dato?
In un Form; con POST o GET?
Ciao Uwe
« Last Edit: May 31, 2010, 06:25:32 am by uwefed » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

allora questo è il client HTML
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
      <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-1252">
      <TITLE>Movimeto Cybot </TITLE>
      <META NAME="GENERATOR" CONTENT="OpenOffice.org 3.2  (Win32)">
      <META NAME="CREATED" CONTENT="0;0">
      <META NAME="CHANGED" CONTENT="20100529;10021400">
      <SCRIPT LANGUAGE="Javascript1.3">
 
    var xmlhttp
            
             function GetXmlHttpObject(){
      if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
              return new XMLHttpRequest();
            document.write("all");
        }
      if (window.ActiveXObject){// code for IE6, IE5
              return new ActiveXObject("Microsoft.XMLHTTP");
            document.write("ie5-6");
        }
      return null;
      document.write("null");
}

function run(url, param){
      xmlhttp = GetXmlHttpObject();
      xmlhttp.open("SEND",url,false);
      xmlhttp.send(param);
}

</SCRIPT>

</HEAD>
<BODY LANG="it-IT" DIR="LTR">
<H1 ALIGN=CENTER><I>Movimento Cybot </I>
</H1>
<FORM ACTION="">
      <P><INPUT TYPE=BUTTON VALUE="avanti" STYLE="width: 1.62cm; height: 0.93cm" ONCLICK="run("192,168,1,2",1)">
      <INPUT TYPE=BUTTON VALUE="indietro" STYLE="width: 1.91cm; height: 0.93cm" ONCLICK="run("192,168,1,2",2)">
      <INPUT TYPE=BUTTON VALUE="destra" STYLE="width: 1.62cm; height: 0.93cm" ONCLICK="run("192,168,1,2",3)">
      <INPUT TYPE=BUTTON VALUE="sinistra" STYLE="width: 1.77cm; height: 0.93cm" ONCLICK="run("192,168,1,2",4)">
      <INPUT TYPE=BUTTON VALUE="stop" STYLE="width: 1.77cm; height: 0.93cm" ONCLICK="run("192,168,1,2",0)">
            </P>

</FORM>
</BODY>
</HTML>


e questo è il server Arduino.

Code:
#include <WiShield.h>

#define WIRELESS_MODE_INFRA      1
#define WIRELESS_MODE_ADHOC      2

// Wireless configuration parameters ----------------------------------------
unsigned char local_ip[] = {192,168,1,2};      // IP address of WiShield
unsigned char gateway_ip[] = {192,168,1,1};      // router or gateway IP address
unsigned char subnet_mask[] = {255,255,255,0};      // subnet mask for the local network
const prog_char ssid[] PROGMEM = {"CYBOT"};            // max 32 bytes
int RHfwd = 8;   // pin motore di dx avanti
int RHbck = 9;   // pin motore di dx indietro
int LHfwd = 10;  // pin motore di sx avanti
int LHbck = 11;  // pin motore di sx indietro
int rit = 200;   // ritardo ad ogni operazione
int n; // lettura dato dal client

unsigned char security_type = 0;      // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2

// WPA/WPA2 passphrase
const prog_char security_passphrase[] PROGMEM = {"12345678"};      // max 64 characters

// WEP 128-bit keys
// sample HEX keys
prog_uchar wep_keys[] PROGMEM = {      0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d,      // Key 0
                                                      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,      0x00,      // Key 1
                                                      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,      0x00,      // Key 2
                                                      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,      0x00      // Key 3
                                                };

// setup the wireless mode
// infrastructure - connect to AP
// adhoc - connect to another WiFi device
unsigned char wireless_mode = WIRELESS_MODE_ADHOC;

unsigned char ssid_len;
unsigned char security_passphrase_len;
//---------------------------------------------------------------------------

void fwd(int r) {  // funzione che permette ai 2 motori di andare avanti
  digitalWrite(RHbck,LOW);
  digitalWrite(LHfwd,HIGH);
  digitalWrite(LHbck,LOW);
  digitalWrite(RHfwd,HIGH);;
  delay(r);
  digitalWrite(RHfwd,LOW);
  digitalWrite(LHfwd,LOW);
}
void back(int r) {  // funzione che permette ai 2 motori di andare indietro
  digitalWrite(RHbck,HIGH);
  digitalWrite(LHfwd,LOW);
  digitalWrite(LHbck,HIGH);
  digitalWrite(RHfwd,LOW);;
  delay(r);
  digitalWrite(RHbck,LOW);
  digitalWrite(LHbck,LOW);
}
// funzione che permette di girare a dx; il motore di dx risulterà in LOW mentre il motore di sx sarà in movimento(HIGH)
void giradx(int r) {  
  digitalWrite(RHbck,LOW);
  digitalWrite(LHbck,LOW);
  digitalWrite(RHfwd,LOW);
  digitalWrite(LHfwd,HIGH);
  delay(r);
  digitalWrite(LHfwd,LOW);
}
// funzione che permette di girare a sx; il motore di sx risulterà in LOW mentre il motore di dx sarà in movimento(HIGH)
void girasx(int r) {
  digitalWrite(RHbck,LOW);
  digitalWrite(LHfwd,LOW);
  digitalWrite(LHbck,LOW);
  digitalWrite(RHfwd,HIGH);
  delay(r);
  digitalWrite(RHfwd,LOW);
}

void setup()
{
      WiFi.init();
        pinMode(RHfwd,INPUT);
        pinMode(RHbck,INPUT);
        pinMode(LHfwd,INPUT);
        pinMode(LHbck,INPUT);
}

// This is the webpage that is served up by the webserver
const prog_char webpage[] PROGMEM = {"HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<center><h1>Hello World!! I am WiShield</h1><form method=\"get\" action=\"0\">Toggle LED:<input type=\"submit\" name=\"0\" value=\"LED1\"></input></form></center>"};

void loop()
{
      WiFi.run();
         if(n==49)
           fwd(rit);
         if(n==50)
           back(rit);
         if(n==51)
           giradx(rit);
         if(n==52)
           girasx(rit);
}

e a questo manca il settaggio per ricevere il parametro... sicuramente sarà WiFi. qualcosa..
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 313
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

centra poco.. forse.. ma io avevo fatto uno script utilizzando mscomm.ocx....
se voi te lo giro ...
ciao
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

va bene dai se puoi passamelo!
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 313
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

devi scaricare .. mscomm.ocx e metterlo o nella cartella del file
oppure in system32..
se hai dei problemi di tasti usa gli imput...
codice html:
Code:
<html><head>





      <title>index</title>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      

</head><body bgcolor="#0000">
<P align=left>
<OBJECT id=lclock style="LEFT: 0px; WIDTH: 577px; TOP: 0px; HEIGHT: 24px"
classid=clsid:978C9E23-D4B0-11CE-BF2D-00AA003F40D0><PARAM NAME="ForeColor" VALUE="16777215"><PARAM NAME="BackColor" VALUE="2147483654"><PARAM NAME="VariousPropertyBits" VALUE="8388635"><PARAM NAME="Caption" VALUE=""><PARAM NAME="PicturePosition" VALUE="458753"><PARAM NAME="Size" VALUE="15266;635"><PARAM NAME="MousePointer" VALUE="0"><PARAM NAME="BorderColor" VALUE="2147483654"><PARAM NAME="BorderStyle" VALUE="0"><PARAM NAME="SpecialEffect" VALUE="0"><PARAM NAME="Accelerator" VALUE="0"><PARAM NAME="FontName" VALUE="Times New Roman"><PARAM NAME="FontEffects" VALUE="1073741824"><PARAM NAME="FontHeight" VALUE="360"><PARAM NAME="FontOffset" VALUE="0"><PARAM NAME="FontCharSet" VALUE="0"><PARAM NAME="FontPitchAndFamily" VALUE="2"><PARAM NAME="ParagraphAlign" VALUE="3"><PARAM NAME="FontWeight" VALUE="400"></OBJECT>
</P>
<P align=left>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<OBJECT id=Command2 classid=clsid:D7053240-CE69-11CD-A777-00DD01143C57><PARAM NAME="ForeColor" VALUE="2147483666"><PARAM NAME="BackColor" VALUE="2147483663"><PARAM NAME="VariousPropertyBits" VALUE="27"><PARAM NAME="Caption" VALUE="Connect"><PARAM NAME="PicturePosition" VALUE="458753"><PARAM NAME="Size" VALUE="2540;847"><PARAM NAME="MousePointer" VALUE="0"><PARAM NAME="Accelerator" VALUE="0"><PARAM NAME="TakeFocusOnClick" VALUE="-1"><PARAM NAME="FontName" VALUE="Times New Roman"><PARAM NAME="FontEffects" VALUE="1073741824"><PARAM NAME="FontHeight" VALUE="240"><PARAM NAME="FontOffset" VALUE="0"><PARAM NAME="FontCharSet" VALUE="0"><PARAM NAME="FontPitchAndFamily" VALUE="2"><PARAM NAME="ParagraphAlign" VALUE="3"><PARAM NAME="FontWeight" VALUE="400"></OBJECT>
<OBJECT id=MSComm1 classid=clsid:648A5600-2C6E-101B-82B6-000000000014><PARAM NAME="_ExtentX" VALUE="1005"><PARAM NAME="_ExtentY" VALUE="1005"><PARAM NAME="_Version" VALUE="393216"><PARAM NAME="CommPort" VALUE="1"><PARAM NAME="DTREnable" VALUE="-1"><PARAM NAME="Handshaking" VALUE="0"><PARAM NAME="InBufferSize" VALUE="1024"><PARAM NAME="InputLen" VALUE="0"><PARAM NAME="NullDiscard" VALUE="0"><PARAM NAME="OutBufferSize" VALUE="512"><PARAM NAME="ParityReplace" VALUE="63"><PARAM NAME="RThreshold" VALUE="0"><PARAM NAME="RTSEnable" VALUE="0"><PARAM NAME="BaudRate" VALUE="9600"><PARAM NAME="ParitySetting" VALUE="0"><PARAM NAME="DataBits" VALUE="8"><PARAM NAME="StopBits" VALUE="0"><PARAM NAME="SThreshold" VALUE="0"><PARAM NAME="EOFEnable" VALUE="0"><PARAM NAME="InputMode" VALUE="0"></OBJECT>
<OBJECT id=Command3 classid=clsid:D7053240-CE69-11CD-A777-00DD01143C57><PARAM NAME="ForeColor" VALUE="2147483666"><PARAM NAME="BackColor" VALUE="2147483663"><PARAM NAME="VariousPropertyBits" VALUE="27"><PARAM NAME="Caption" VALUE="DisConnect"><PARAM NAME="PicturePosition" VALUE="458753"><PARAM NAME="Size" VALUE="2540;847"><PARAM NAME="MousePointer" VALUE="0"><PARAM NAME="Accelerator" VALUE="0"><PARAM NAME="TakeFocusOnClick" VALUE="-1"><PARAM NAME="FontName" VALUE="Times New Roman"><PARAM NAME="FontEffects" VALUE="1073741824"><PARAM NAME="FontHeight" VALUE="240"><PARAM NAME="FontOffset" VALUE="0"><PARAM NAME="FontCharSet" VALUE="0"><PARAM NAME="FontPitchAndFamily" VALUE="2"><PARAM NAME="ParagraphAlign" VALUE="3"><PARAM NAME="FontWeight" VALUE="400"></OBJECT>
</P>
<P align=left>&nbsp;&nbsp;</P>
<P align=left>
<OBJECT id=Text1 style="LEFT: 0px; WIDTH: 288px; TOP: 0px; HEIGHT: 105px"
classid=clsid:8BD21D10-EC42-11CE-9E0D-00AA006002F3><PARAM NAME="VariousPropertyBits" VALUE="3967830043"><PARAM NAME="BackColor" VALUE="2147483654"><PARAM NAME="ForeColor" VALUE="2147483652"><PARAM NAME="MaxLength" VALUE="0"><PARAM NAME="BorderStyle" VALUE="0"><PARAM NAME="ScrollBars" VALUE="2"><PARAM NAME="DisplayStyle" VALUE="1"><PARAM NAME="MousePointer" VALUE="0"><PARAM NAME="Size" VALUE="7620;2778"><PARAM NAME="PasswordChar" VALUE="0"><PARAM NAME="ListWidth" VALUE="0"><PARAM NAME="BoundColumn" VALUE="1"><PARAM NAME="TextColumn" VALUE="65535"><PARAM NAME="ColumnCount" VALUE="1"><PARAM NAME="ListRows" VALUE="8"><PARAM NAME="cColumnInfo" VALUE="0"><PARAM NAME="MatchEntry" VALUE="2"><PARAM NAME="ListStyle" VALUE="0"><PARAM NAME="ShowDropButtonWhen" VALUE="0"><PARAM NAME="ShowListWhen" VALUE="1"><PARAM NAME="DropButtonStyle" VALUE="1"><PARAM NAME="MultiSelect" VALUE="0"><PARAM NAME="Value" VALUE=""><PARAM NAME="Caption" VALUE=""><PARAM NAME="PicturePosition" VALUE="458753"><PARAM NAME="BorderColor" VALUE="2147483654"><PARAM NAME="SpecialEffect" VALUE="2"><PARAM NAME="Accelerator" VALUE="0"><PARAM NAME="GroupName" VALUE=""><PARAM NAME="FontName" VALUE="Times New Roman"><PARAM NAME="FontEffects" VALUE="1073741824"><PARAM NAME="FontHeight" VALUE="240"><PARAM NAME="FontOffset" VALUE="0"><PARAM NAME="FontCharSet" VALUE="0"><PARAM NAME="FontPitchAndFamily" VALUE="2"><PARAM NAME="ParagraphAlign" VALUE="1"><PARAM NAME="FontWeight" VALUE="400"></OBJECT>
<OBJECT id=Text2 style="WIDTH: 93px; HEIGHT: 28px"
classid=clsid:8BD21D10-EC42-11CE-9E0D-00AA006002F3><PARAM NAME="VariousPropertyBits" VALUE="746604571"><PARAM NAME="BackColor" VALUE="2147483653"><PARAM NAME="ForeColor" VALUE="2147483656"><PARAM NAME="MaxLength" VALUE="0"><PARAM NAME="BorderStyle" VALUE="0"><PARAM NAME="ScrollBars" VALUE="0"><PARAM NAME="DisplayStyle" VALUE="1"><PARAM NAME="MousePointer" VALUE="0"><PARAM NAME="Size" VALUE="2461;741"><PARAM NAME="PasswordChar" VALUE="0"><PARAM NAME="ListWidth" VALUE="0"><PARAM NAME="BoundColumn" VALUE="1"><PARAM NAME="TextColumn" VALUE="65535"><PARAM NAME="ColumnCount" VALUE="1"><PARAM NAME="ListRows" VALUE="8"><PARAM NAME="cColumnInfo" VALUE="0"><PARAM NAME="MatchEntry" VALUE="2"><PARAM NAME="ListStyle" VALUE="0"><PARAM NAME="ShowDropButtonWhen" VALUE="0"><PARAM NAME="ShowListWhen" VALUE="1"><PARAM NAME="DropButtonStyle" VALUE="1"><PARAM NAME="MultiSelect" VALUE="0"><PARAM NAME="Value" VALUE=""><PARAM NAME="Caption" VALUE=""><PARAM NAME="PicturePosition" VALUE="458753"><PARAM NAME="BorderColor" VALUE="2147483654"><PARAM NAME="SpecialEffect" VALUE="2"><PARAM NAME="Accelerator" VALUE="0"><PARAM NAME="GroupName" VALUE=""><PARAM NAME="FontName" VALUE="Times New Roman"><PARAM NAME="FontEffects" VALUE="1073741824"><PARAM NAME="FontHeight" VALUE="240"><PARAM NAME="FontOffset" VALUE="0"><PARAM NAME="FontCharSet" VALUE="0"><PARAM NAME="FontPitchAndFamily" VALUE="2"><PARAM NAME="ParagraphAlign" VALUE="1"><PARAM NAME="FontWeight" VALUE="400"></OBJECT>
<OBJECT id=Command1 style="WIDTH: 96px; HEIGHT: 29px"
classid=clsid:D7053240-CE69-11CD-A777-00DD01143C57><PARAM NAME="ForeColor" VALUE="2147483666"><PARAM NAME="BackColor" VALUE="2147483663"><PARAM NAME="VariousPropertyBits" VALUE="27"><PARAM NAME="Caption" VALUE="Send"><PARAM NAME="PicturePosition" VALUE="458753"><PARAM NAME="Size" VALUE="2540;767"><PARAM NAME="MousePointer" VALUE="0"><PARAM NAME="Accelerator" VALUE="0"><PARAM NAME="TakeFocusOnClick" VALUE="-1"><PARAM NAME="FontName" VALUE="Times New Roman"><PARAM NAME="FontEffects" VALUE="1073741824"><PARAM NAME="FontHeight" VALUE="240"><PARAM NAME="FontOffset" VALUE="0"><PARAM NAME="FontCharSet" VALUE="0"><PARAM NAME="FontPitchAndFamily" VALUE="2"><PARAM NAME="ParagraphAlign" VALUE="3"><PARAM NAME="FontWeight" VALUE="400"></OBJECT>
</P>
<P align=left>
</P>
<P align=left>
</P>


<script language="vbscript">



Dim a , rr, AA
Dim Nporta, settaggio, cc
Dim Stringa
Dim RIGA

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set filesys = CreateObject("Scripting.FileSystemObject")
'Set filetxt = filesys.OpenTextFile("c:\somefile.txt", ForAppending, True)
'filetxt.WriteLine("Your text goes here.")
'filetxt.Close
'public sub Start_Click()
      
      
      'a = 1
      'Text0_0.Text = date()
      'set filetxt = filesys.OpenTextFile("appoggio.dat", ForReading)
      'rr = filetxt.ReadLine
      'Text1_0 = CStr(rr)
   ' filetxt.Close
      

'end sub



Private Sub Command1_Click()
On Error Resume Next
If MSComm1.PortOpen = True Then
    MSComm1.Output = Text2.Text
    Text2 = ""
End If

End Sub

Private Sub Command2_Click()
    
    If MSComm1.PortOpen = False Then
        MSComm1.CommPort = 3
       MSComm1.Settings = "9600, N, 8, 1"
        MSComm1.RThreshold = 1
        MSComm1.PortOpen = True
    
    End If

End Sub

Private Sub Command3_Click()

If MSComm1.PortOpen = True Then
    
    MSComm1.PortOpen = False

End If

End Sub




Private Sub Command7_Click()
If MSComm1.PortOpen = True Then
    
    For AA = 1 To 6000
    'doevents
    Label1.Caption = AA
    Next
    
    MSComm1.Output = "B"
    
    For AA = 1 To 6000
    'doevents
    Label1.Caption = AA
    Next
    
    MSComm1.Output = "B"
    
    
    For AA = 1 To 6000
    'doevents
    Label1.Caption = AA
    
    Next
        MSComm1.Output = "000"

End If



End Sub





Private Sub Label1_Change()
'Shape1.BackColor = vbRed
'If Label1.Caption = 6000 Then Shape1.BackColor = vbGreen
End Sub

Private Sub MSComm1_OnComm()
Dim Buffer
 'doevents
    Buffer = MSComm1.Input
    Text1.Text = Text1.Text & Buffer
    lclock.Caption = Now

End Sub











</script>


</body>
</HTML>

Logged

Pages: [1]   Go Up
Jump to: