ducción del español al inglés
I'm trying to build something with one joystic, I went well, and I read the Trembler and printed at the port for communication.
Now, a detailed
the receiver and interpret the reading for that output switch leave the cod to use for the issuer.
joyPin1 = 0, / / ??variable x-axis
joyPin2 int = 1, / / ??variable Y
int value1 = 0;
int value2 = 0;
void setup () {
pinMode (ledPin, OUTPUT) / / Starts the digital outputs
Serial.begin (9600);
}
treatValue int (int data) {
return (data * 9 / 1024) + 48;
}
void loop () {/ / Read the values ??of the pot 1.
value1 = analogRead (joyPin1)
delay (100);
value2 = analogRead (joyPin2) / / potentiometer 2
digitalWrite (ledPin, HIGH);
delay (value1);
digitalWrite (ledPin, LOW);
delay (value2);
Serial.write ('J');
Serial.write (treatValue (value1));
Serial.write (treatValue (value2));
Serial.write (10);
Serial.write (13);
}
in this all leave aprente well read port
J44
J64
J84
J04
J40
J40
J40
J48
J48
J40
J48
J44
J44
J44
the 44 is the center of the lever
enotnces Now comes the good when I try to read it in the arduino port, use this value as to turn a digital output.
try this
const int ledPin = 13, / / ??the pin That the LED is attached to
incomingByte int, / / ??a variable to read incoming serial data Into
void setup () {
/ / Initialize serial communication:
Serial.begin (9600);
/ / Initialize the LED pin as an output:
pinMode (ledPin, OUTPUT);
}
void loop () {
/ / See if There's incoming serial data:
if (Serial.available ()> 0) {
/ / Read the byte in the serial Oldest buffer:
serial.rar incomingByte = ();
/ / If it's a capital H (ASCII 72), turn on the LED:
if (incomingByte == 'H') {
digitalWrite (ledPin, HIGH);
}
/ / If it's an L (ASCII 76) turn off the LED:
if (incomingByte == 'L') {
digitalWrite (ledPin, LOW);
}
}
}
but only accepts the h only attempt to change by the J40 or any of those prints, but no. So here aver if I can help.
did anyone know how to code the video