Re: [Tutor] Python Arduino Web Page

2013-08-15 Thread Dave Angel
Engineering wrote:

   

> 
> 

[Tutor] Python & Arduino

2013-08-12 Thread Engineering
Dear All

 

I have designed a small program to control an arduino through python socket
server. The front end is the Javaquery. My HTML code is given below

 

$(function() {

$( "#slider" ).slider({

  min: 0,

  max: 180,

  step: 10,

  slide: function( event, ui ) {

$( "#amount" ).val( "$" + ui.value );

  }

});

$( "#amount" ).val( "$" + $( "#slider" ).slider( "value" ) );

  });

 

My python websocket code is given below

from twisted.internet import reactor

print "Using Twisted reactor", reactor.__class__

print

 

from twisted.python import usage, log

from twisted.protocols.basic import LineReceiver

from twisted.internet.serialport import SerialPort

from twisted.web.server import Site

from twisted.web.static import File

 

from autobahn.websocket import listenWS

from autobahn.wamp import WampServerFactory, WampServerProtocol, exportRpc

 

 

class Serial2WsOptions(usage.Options):

   optParameters = [

  ['baudrate', 'b', 9600, 'Serial baudrate'],

  ['port', 'p', 26, 'Serial port to use'],

  ['webport', 'w', 8080, 'Web port to use for embedded Web server'],

  ['wsurl', 's', "ws://localhost:9000", 'WebSocket port to use for
embedded WebSocket server']

   ]

 

Can you please help me with the python code . I want the server to write
string which will be sent to the arduino digital pin to control the servo. 

The arduino can have the following in its code

 

if(!Serial.available())

  {

// convert String to int. 

int recievedVal = stringToInt();



//analogWrite(servoPin,recievedVal);

recievedVal = map(recievedVal,0,179,0,179);

webcam.write(recievedVal);

delay(15);

pwmComplete = false;

  }

 

Python side coding help is required

 

CLEANTECH SOLUTION

www.cleantechsolution.in

 

SAVE PAPER , SAVE EARTH

 

 

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Python Arduino Web Page

2013-08-11 Thread Engineering
I have written the following code in Python for my Arduino

 

#!c:\Python27\Python.exe

import cgi, cgitb;

import sys, serial

cgitb.enable()

ser = serial.Serial('COM27', 9600)

myvar = ser.readline()

print "Content-type:text/html\n\n"

print """







Real Time Temperature



  

window.onload = startInterval;

function startInterval()

{

setInterval("startTime();",1000);

}

 

function startTime(myvar)

{

document.getElementById('mine').innerHTML ="Temperature"
+parseInt(myvar);

 

}

  





Real Time Temperature:





"""

I have Apache Web Server 

But on running this  my localhost , I am getting the following output
"TemperatureNaN" . Why is NaN being showed. Why cant I get the number as
read by se.readline()?

Is there a way to separate the Python code and the Javascript on different
files. If so can you please give a example.?

I am not really interested to do with bottle or other web framework as I
will be controlling my arduino with python from the web and also do video
image processing with openCV. Open CV have a support for Python and not for
Javascript.

 

Thanks

Subhendu Sinha Chaudhuri

 

CLEANTECH SOLUTION

www.cleantechsolution.in

 

SAVE PAPER , SAVE EARTH

 

 

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor