Go Down

Topic: Led Matrix Processing, arduino control problems (Read 967 times) previous topic - next topic

Rilart

Hi, thanks for your time btw!

now, i created a led matrix in processing with some tutorials in the internet. next step was building a kind of controler with 4 directional moves (up, down, left, right) and enter/reset pixel. but im stuck with the code in the arduino, heres my code of arduino a and processing.
thaaaaaanks


teorically (for me), the controller is ok. but when i tried to move the led in my processing code they not work.
my guess will be that my arduino code is not sending the move of the led to the processing program.

Code: [Select]

const int PaddleLeft = 0;  // Paddle, posicion izq
const int PaddleRight = 100;  // Paddle, posicion der
const int PaddleRefresh = 20;  // Checa cada 20 ml el paddle
const int SerialRefresh = 2000;  // checa la posicion del Paddle cada 2 seg

int Y1_lesspin = 2;
int Y1_pluspin = 4;
int Y2_lesspin = 6;
int Y2_pluspin = 8;
int Y1=0;
int Y2=0;

void setup() {
Serial.begin(9600);


pinMode(Y1_lesspin, INPUT);
pinMode(Y1_pluspin, INPUT);
pinMode(Y2_lesspin, INPUT);
pinMode(Y2_pluspin, INPUT);


}

void loop() {
   static int paddle1position = (PaddleLeft + PaddleRight) / 2; // Centra el Paddle 1 al comenzar el juego
   static int paddle2position = (PaddleLeft + PaddleRight) / 2; // Centra el Paddle 2 al comenzar el juego
   static unsigned long lastpaddlerefresh;  
   static unsigned long lastserialrefresh;  

 
int Y1_less = digitalRead( Y1_lesspin);
 
int Y1_plus = digitalRead( Y1_pluspin);

int Y2_less = digitalRead( Y2_lesspin);
 
int Y2_plus = digitalRead( Y2_pluspin);

//CONTROL 1

if (Y1_less == HIGH && Y1_plus == LOW && Y1>10)
{
Y1 = Y1 -2;

}
 if (Y1_less == LOW && Y1_plus == HIGH && Y1 < 245)

{

Y1 = Y1 +2;
}  

//CONTROL DOS

  if (Y2_less == HIGH && Y2_plus == LOW && Y2>10)

{
Y2 = Y2 -2;
 
}
 if (Y2_less == LOW && Y2_plus == HIGH && Y2 < 245)
{

Y2 = Y2 +2;
 
}  
 
 
 if(true)
 {
     Serial.print (0,BYTE);
     Serial.print (1,BYTE);
     Serial.print ((byte) Y1,BYTE);
     Serial.print (0,BYTE);
     Serial.print (2,BYTE);
     Serial.print ((byte) Y2,BYTE);
 }
     else
     {
   
     Serial.println (Y1);
   
     Serial.println (Y2);
   }
     delay (10);
}

PaulS

There's really no need to guess. In the Processing application, print out the data received from the serial port. Do you get anything? Does it match what you are sending from the Arduino. If not, the problem might be with the Arduino. On the other hand it might be with the Processing application.

Is this by any chance related to this thread, where apparently you didn't like the answers you were getting?
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1291357870/4

Rilart

Yes , thats my older post... I tried to delete it...well.

Ill do what you said, Thanks

Go Up