We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, So my problem I think is quite simple, I am trying to communicate a degree change from a piece of colour tracking to arduino. At the moment I get information from processing to arduino but it is scrambled and incorrect. Basically tempAngle is my change in angles and I want arduino to read it in the serial monitor.
Arduino Code: int incomingByte = 0; // for incoming serial data
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}
void loop() {
// send data only when you receive data:
//if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
// say what you got:
print("I received: ");
println(incomingByte, DEC);
//}
}
Processing Code:
if ((bigX<320)&&(bigY<240)) { //Square 1
tempX = 320-bigX;
tempY = 240-bigY;
currentAngle = (180 + (90-(degrees (atan(tempX/tempY)))));
println("SQ1");
//ARM
stroke(0, 0, 0);
strokeWeight(5);
pushMatrix();
translate(width/2, height/2);
//rotate(radians(180));
rotate(radians(currentAngle));
line(0, 0, 150, 0);
println("rotation:" + currentAngle);
tempAngle = (currentAngle - previousAngle);
myPort.write(int(tempAngle));
println("difference is: " + tempAngle);
previousAngle = currentAngle;
popMatrix();
}
Thanks for taking a look.
Answers
Also I don't get negative readings, which I need
your question doesn't seem complete. by degree do you mean temperature from a temperature sensor? you ommited part of your processing code that gets information from arduino, and you ommited arduino code that gets data from sensor and sends it back (it seems to just send back echo of what it receives from the serial port)