1 / 24

Tele-presence – Connecting Two Processing Platforms via Internet

Tele-presence – Connecting Two Processing Platforms via Internet Controlling the Screen based on Distant User Input. Server. Client. Tele-presence – Connecting Two Processing Platforms via Internet Controlling the Screen based on Distant User Input. Server. Client. Tele-presence –

Télécharger la présentation

Tele-presence – Connecting Two Processing Platforms via Internet

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Tele-presence – Connecting Two Processing Platforms via Internet Controlling the Screen based on Distant User Input Server Client

  2. Tele-presence – Connecting Two Processing Platforms via Internet Controlling the Screen based on Distant User Input Server Client

  3. Tele-presence – Connecting Two Processing Platforms via Internet Controlling the Screen based on Distant User Input • On the Computer that the server is supposed to run: • Connect to Internet • Go to “what is my IP Adress website and check the current IP address • Run the Server Side Processing Code • On the Computer that the client is supposed to run: • Connect to Internet • Change the IP Address variable to the one that is provided from the server computer • Run the Client Side Processing Code

  4. Tele-presence – Connecting Two Processing Platforms via Internet Controlling the Screen based on Distant User Input Obtaining IP Address of the Server : http://whatismyip.com/ IP Address (Internet Protocol Address): This number is an exclusive number all information technology devices (printers, routers, modems, et al) use which identifies and allows them the ability to communicate with each other on a computer network. There is a standard of communication which is called an Internet Protocol standard (IP). In laymans terms it is the same as your home address. In order for you to receive snail mail at home the sending party must have your correct mailing address (IP address) in your town (network) or you do not receive bills, pizza coupons or your tax refund. The same is true for all equipment on the internet. Without this specific address, information cannot be received.

  5. Tele-presence – Connecting Two Processing Platforms via Internet Controlling the Screen based on Distant User Input // This is code for Client import processing.net.*; Client myClient; String inString=“000000000; //Change to Provided ipAddress from Server // For simulating Client and Server on the same System “127.0.0.1” String ipAddress="127.0.0.1"; String Red, Green, Blue; void setup() { size (300, 100); myClient = new Client(this, ipAddress , 5204); } void draw() { if (myClient.available() > 0) { inString = myClient.readString(); delay(300); //delay is necessary to avoid system failure println(inString); } // Reading three different data parts fromone incoming string Red = inString.substring(0,3); Green =inString.substring(3,6); Blue = inString.substring(6,9); color c=color(int(Red),int(Green),int(Blue)); background(c); } //This is the code for Server import processing.net.*; Server myServer; int port = 5204; int val = 0; void setup() { size(100,100); // Starts a myServer on port 5204 myServer = new Server(this, port); // Change the hue, saturation and brightness constant // Paint the screen colorMode(HSB); for (int i = 0; i <100; i++) { stroke(i*2.5, 255, 255);//stroke(hue,Saturation,Brightness) line(i, 0, i, 100); println(i); } } void draw() { color c = get(mouseX,mouseY); int Red = int(red(c)); int Green = int(green(c)); int Blue = int(blue(c)); // Write the color as a string built of three sets of three digit codes for R G and B String Value = nf (Red,3)+nf (Green,3)+nf (Blue,3); myServer.write(Value); println(Value); }

  6. Tele-presence – Connecting Two Processing Platforms via Internet Controlling the Screen based on Distant Arduino Input Server Client

  7. Tele-presence – Connecting Two Processing Platforms via Internet Controlling the Screen based on Distant Arduino Input // This is Arduino Code void setup(){ Serial.begin(9600); } void loop(){ int in = analogRead(5); Serial.println(in); } //This is the code for Server import processing.net.*; import processing.serial.*; //Change based on range of data read in space intminVal=400; intmaxVal=900; Server myServer; Serial port; intInternetPort = 5204; intval = 0; String buff = ""; int NEWLINE = 10; void setup() { size(100,100); //connect to Internet // Starts a myServer on port 5204 myServer = new Server(this, InternetPort); //Connect to Arduino // Use the first available port port = new Serial(this, Serial.list()[1], 9600); // if in arduino the first option in your list is the port that you are connecting to, //change the 1 to Zero, if it is the second leave it as 1 println(Serial.list()); background(255); } void draw() { while (port.available() > 0) serialEvent(port.read()); //look for data background(val); //println(val); String Value = nf (val,3); myServer.write(Value); } void serialEvent(int serial) { // If the variable "serial" is not equal to the value for // a new line, add the value to the variable "buff". If the // value "serial" is equal to the value for a new line, // save the value of the buffer into the variable "val". if(serial != NEWLINE) { buff += char(serial); } else { buff = buff.substring(0, buff.length()-1); // Parse the String into an integer val = Integer.parseInt(buff); val=int(map(val,minVal,maxVal,0,255)); // Clear the value of "buff" buff = ""; } } // This is the code for Client import processing.net.*; Client myClient; String inString; String grayColor=“000”; //Change to Provided ipAddress from Server // For simulating Client and Server on the same System “127.0.0.1” String ipAddress="127.0.0.1"; void setup() { size (300, 100); myClient = new Client(this, ipAddress , 5204); } void draw() { if (myClient.available() > 0) { inString = myClient.readString(); delay(300); //delay is necessary to avoid system failure } // Convering the incoming data to background color grayColor=inString.substring(0,3); background(int(grayColor)); println(grayColor); }

  8. Tele-presence – Connecting Two Processing Platforms via Internet Controlling Arduino Output based on Distant Arduino Input Server Client

  9. Tele-presence – Connecting Two Processing Platforms via Internet Controlling Arduino Output based on Distant Arduino Input //This is the code for Server import processing.net.*; import processing.serial.*; Server myServer; Serial port; int InternetPort = 5204; int val = 0; String buff = ""; int NEWLINE = 10; void setup() { size(100,100); //connect to Internet // Starts a myServer on port 5204 myServer = new Server(this, InternetPort); //Connect to Arduino // Use the first available port port = new Serial(this, Serial.list()[1], 9600); // if in arduino the first option in your list is the port that you are connecting to, //change the 1 to Zero, if it is the second leave it as 1 println(Serial.list()); background(255); } void draw() { while (port.available() > 0) serialEvent(port.read()); //look for data background(val); //println(val); String Value = nf (val,3); myServer.write(Value); } void serialEvent(int serial) { // If the variable "serial" is not equal to the value for // a new line, add the value to the variable "buff". If the // value "serial" is equal to the value for a new line, // save the value of the buffer into the variable "val". if(serial != NEWLINE) { buff += char(serial); } else { buff = buff.substring(0, buff.length()-1); // Parse the String into an integer val = Integer.parseInt(buff); val=int(val); // Clear the value of "buff" buff = ""; } } // This is the code for Client import processing.net.*; import processing.serial.*; Serial myPort; Client myClient; String inString=“000”; String grayColor; //Change to Provided ipAddress from Server // For simulating Client and Server on the same System “127.0.0.1” String ipAddress="127.0.0.1"; void setup() { myClient = new Client(this, ipAddress , 5204); myPort = new Serial(this, Serial.list()[8], 9600); } void draw() { if (myClient.available() > 0) { inString = myClient.readString(); delay(50); //delay is necessary to avoid system failure } // Convering the incoming data to background color println(inString); println("OK"); if (inString!=null) { inString=inString.substring(0,3); background(int(inString)); myPort.write(int(inString)); } } // This is Arduino Code int avrage; void setup(){ Serial.begin(9600); for (int i=0; i<20; i++){ avrage=avrage+analogRead(5); } avrage=avrage/20; } void loop(){ int in = analogRead(5); if (in<avrage-50){ in=200;//Turn On Light Serial.println(in); }else{ in=100;//Turn Off Light Serial.println(in); } } int val = 0; void setup() { pinMode(13, OUTPUT); // sets the digital pin as output Serial.begin(9600); } void loop() { val = Serial.read(); if (val==100){digitalWrite(13,LOW);} if (val==200){digitalWrite(13,HIGH);} }

  10. Tele-presence – Connecting Two Processing Platforms via Internet Controlling Arduino Output based on Distant Arduino Input

  11. Tele-presence – Connecting Two Processing Platforms via Internet Controlling Arduino Output based on Distant Arduino Input

  12. Tele-presence – Connecting Two Processing Platforms via Internet Controlling Arduino Output based on Distant Arduino Input

  13. Tele-presence – Connecting Two Processing Platforms via Internet Controlling Arduino Output based on Distant Arduino Input

  14. Tele-presence – Connecting Two Processing Platforms via Internet Controlling Arduino Output based on Distant Arduino Input

  15. Tele-presence – Connecting Two Processing Platforms via Internet Controlling Arduino Output based on Distant Arduino Input

  16. Tele-presence – Connecting Two Processing Platforms via Internet Controlling Arduino Output based on Distant Arduino Input • First Arduino Connects to The first Processing Using Serial Port. • Serial.begin(9600);//Open Serial Port • Serial.println(in);//Sending Data via Serial Port • First Processing Function as a Server Connecting To the Second Processing via Net, Reading Data from Arduino Using Serial Port and Sending Data to Client Processing Using Net • import processing.net.*;//Importing the net library to Connect to Second Processing and Send Data to it • import processing.serial.*;//Importing serial Library to Connect to Arduino and Read from It • Server myServer;//Initiating a Server to Send data to Client via net • Serial port;//Initiating a Serial Port to Receive Data from Arduino • myServer = new Server(this, InternetPort); //Connect to Internet by Starting myServer on port 5204 • port = new Serial(this, Serial.list()[1], 9600); //Connect to Arduino Use the first available port • myServer.write(Value);//Send data to the client Processing via Net • Second Processing Functions as a Client Connecting to the First Processing via Net, Reading Data from Server Processing Using Net and Sending Data to the Second Arduino Using Serial Port • import processing.net.*; • import processing.serial.*; • Serial myPort; //Innitiate a Serial Port • Client myClient; //Innitiate a Client • myClient = new Client(this, ipAddress , 5204); //Begin Client Connection to Server • myPort = new Serial(this, Serial.list()[8], 9600);//Begin Serial Port • inString = myClient.readString();//Receive Data from Server via Net • myPort.write(int(inString));//Send Data to Arduino via Serial Port • Second Arduino Connects to Client Processing and Read Data from it via Serial Port • 1. Serial.begin(9600);//Open Serial Connection • 2. val = Serial.read();//Read Data from Serial Port

  17. Tele-presence – Connecting Two Processing Platforms via Internet Controlling Arduino Output based on Distant Arduino Input

  18. (Client and Server on Different Computers) Tele-presence – Connecting Two Processing Platforms via Internet Controlling Arduino Output based on Distant Arduino Input vs. (Client and Server on the Same Computer) Synchronized Input/Output- Actuating the Physical Space and Monitoring the Physical Properties of the Space at the same time

  19. Things that Talk to Eachother Connecting Two Arduino Together Master Slave Master Arduino Can control the Slave Arduino by Sending Data to it. Thus it is better to connect the devices that monitor the space and sense the changes in the physical properties of the space to the Master one and connect the Actoators of the space that are activated based on sensed changes in physical properties of the space to the Slave one Master/Slave connection is one way if you are short in digital or analog pins and have more sensors and actoators than the pins that are available on one Arduino

  20. Things that Talk to Eachother Hardware Serial Connection on TX and RX

  21. Things that Talk to Eachother Hardware Serial Connection on TX and RX //Master void setup(){ Serial.begin(9600); pinMode(13,OUTPUT); } void loop(){ digitalWrite(13,HIGH); Serial.println(0); delay(1000); digitalWrite(13,LOW); Serial.println(1); delay(1000); } //Slave void setup(){ Serial.begin(9600); pinMode(13,OUTPUT); } void loop(){ int in=Serial.read(); if (in==48){ digitalWrite(13,HIGH); } if(in==49){ digitalWrite(13,LOW); } }

  22. Things that Talk to Each other Software Connection on pin2 and pin3

  23. Things that Talk to Each other Software Connection on pin2 and pin3 // this is the code for the arduino board which is the master // the master can control the slave arduino board if connected to it // through hardware serial port tx1 and rx0 or software serial ports // which are introduced with softwareserial library // in this program we are transforming digital pin 2 and 3 to serial transmitter and reciever // connect this arduino to the other arduino via digital pin 2 and 3 // pin 2 of master arduino board is connected to pin 3 of the slave arduino board // pin 3 of master arduino board is connected to pin 2 of the slave arduino board #include <SoftwareSerial.h> #define rxPin 2 #define txPin 3 SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin); void setup(){ pinMode(rxPin, INPUT); pinMode(txPin, OUTPUT); pinMode(13,OUTPUT); Serial.begin(9600); mySerial.begin(9600); } void loop(){ if(millis()%2000<1000){ digitalWrite(13,HIGH); mySerial.println(0); } if(millis()%2000>1000){ digitalWrite(13,LOW); mySerial.println(1); } } // this is the code for slave board // connect the slave board to the master board via digital pin 2 and 3 // 3 on slave to 2 on master and 2 on slave to 3 on master #include <SoftwareSerial.h> #define rxPin 2 #define txPin 3 SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin); void setup(){ pinMode(rxPin, INPUT); pinMode(txPin, OUTPUT); pinMode(13,OUTPUT); Serial.begin(9600); mySerial.begin(9600); } void loop(){ char in=mySerial.read(); Serial.println(in); if (in==48){ digitalWrite(13,HIGH); } if(in==49){ digitalWrite(13,LOW); } }

  24. Things that Talk to Eachother Multiple Software Connections To TX / RX To TX / RX To TX / RX To TX / RX

More Related