Potentiometer Value Going Haywire When Sending Serial Data to Processing

Hello all,
I am creating a code in processing that reads the value of an arduino potentiometer and uses it to move an object base off of it’s coordinate points. The potentiometer works flawlessly in arduino, displaying the values properly. It also works flawlessly in processing when used as a value and used with ‘simple’ math such as addition or subtraction. However when using sine and cosine, the value read by the potentiometer begins to act haywire and sporadic. My goal is to have the potentiometer represent a joint in the body and have a point calculated based off of the input of the potentiometer.
Here are my codes, they are attached as well. Any help and comments extremely helpful.
Thanks, G

Arduino Code:

int potPin0 = 0; //pin 0  //Define Pins

void setup()
  Serial.begin(9600);//Create Serial Object (9600 Baud)

void loop()
  int val = map(analogRead(potPin0), 0, 1023, 0, 270); //(0 is the potentiometer low, 1023 is the high, 0 is the value we make low, 270 is value high because of degree rotation)
  if (val > 270)
  Serial.println(val);// the val its printing is between 0 and 270 as specified above
  delay(500); // cant have it going extremely fast because then it wont have time to process

Processing Code:

import processing.serial.*;
Serial port;
float brightness = 0;
 int limb = 50;

void setup()
  port = new Serial(this, "/dev/cu.usbmodem1421", 9600);

void draw()
  background(0,0,0); //background of pic
  fill(255, 255, 255);
  ellipse(250, 100, 75, 75); // head
  line(250, 136, 250, 300);//spine
    stroke(255, 255, 255);
    line(250, 300, (limb * (cos(brightness)) + 350), (limb * (sin(brightness)) + 350));
void serialEvent (Serial port)
  brightness = float(port.readStringUntil('\n'));

TJ_Processing_1.pde (592 Bytes)

TJ_Working_Arduino.ino (490 Bytes)


The cosine function as other trig functions take their arguments in radians not degrees.

Thanks! That did it.