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.
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);
}