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

Reply via email to