Robot Processing

import guicomponents.*;

// Example by Tom Igoe

int delayTime=1000;
GWSlider sdr1, sdr2, sdr3, sdr4, sdr5, sdr6, sdr7;



import processing.serial.*;

// The serial port:
Serial myPort;       
void setup()
{
  
  size(600, 240); 
// List all the available serial ports:
println(Serial.list());

// Open the port you are using at the rate you want:
myPort = new Serial(this, Serial.list()[2], 115200);
  
// Send a capital A out the serial port:
myPort.clear();

  robotInit();

  sdr1 = new GWSlider(this,"blue18px",20,20,260);
  sdr1.setValueType(GWSlider.INTEGER);
  sdr1.setLimits(1500, 750, 2250);
  sdr1.setRenderValueLabel(false); 
  sdr1.tagNo=1;

  sdr2 = new GWSlider(this,"blue18px",20,80,260);
  sdr2.setValueType(GWSlider.INTEGER);
  sdr2.setLimits(1500, 750, 2250);
  sdr2.setRenderValueLabel(false); 

  sdr2.tagNo=2;

}



void robotInit()
{

  // Main lever
myPort.write("#4 P1000 T500\n");
myPort.write(13);
delay(500);

// Main Arm Raise - 1500 middle
myPort.write("#16 P1500 T500\n");
myPort.write(13);
delay(500);


// Gripper Rotate
myPort.write("#20 P750 T500\n");
myPort.write(13);
delay(500);

// Gripper
myPort.write("#24 P500 T500\n");
myPort.write(13);
delay(2000);
myPort.write("#24 P2250 T500\n");
myPort.write(13);
delay(500);


//GRiiper Lever
myPort.write("#28 P2250 T500\n");
myPort.write(13);
delay(2000);

// Main Rotate 500 - 2250
myPort.write("#0 P500 T500");
myPort.write(13);
delay(2000);

// Main Rotate 500 - 2250
myPort.write("#0 P2250 T500");
myPort.write(13);

}

void draw()

{
 
   background(200,200,255);
  
  
}

void handleSliderEvents(GSlider slider) {
  //println(slider.tagNo);
  //println("integer value:" + slider.getValue() + " float value:" + slider.getValuef());
  
  if ( slider.tagNo == 1 ) 
  {
   
    myPort.write("#0 P" +slider.getValue()+  "T500");
    myPort.write(13);
    //delay(500);

      
    
  }
  
  
  if ( slider.tagNo == 2 ) 
  {
   
    myPort.write("#24 P" +slider.getValue()+  "T500");
    myPort.write(13);
    //delay(500);

      
    
  }
  
  
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s