Boa noite pessoal!

Venho tentando a vários dias fazer com que um led altere seu brilho, usando 2 xbee e 2 arduinos, me baseie nos seguintes códigos:

// TRANSMISSOR
int analogValue2, analogValue5, val2, val5;

void setup()
{
// start serial port at 19200 bps
Serial.begin(19200);
}

void loop()
{
// read analog input
analogValue2 = analogRead(2);
analogValue5 = analogRead(5);

val2 = map(analogValue2, 0, 1023, 253, 0);  // 254 and 255 for SYNC
val5 = map(analogValue5, 0, 1023, 253, 0);

Serial.print(254, BYTE); //SYNC char
Serial.print(val2, BYTE);

Serial.print(255, BYTE); //SYNC char
Serial.print(val5, BYTE);

delay(150);
}
// RECEPTOR

byte incomingByte, sensor1, sensor2;

void setup() {

// start serial port at 19200 bps
Serial.begin(19200);
Serial.println(”Ready!”);

pinMode (5, OUTPUT);
pinMode (6, OUTPUT);

delay(1000);

}

void loop() {

if (Serial.available()) {
incomingByte = Serial.read();

Serial.print(int(incomingByte));

if ((int(incomingByte) == 254)) {
sensor1 = Serial.read();
Serial.print(”Sensor 1 = “);
Serial.print(int(sensor1));
}

if ((int(incomingByte) == 255)) {
sensor2 = Serial.read();
Serial.print(”  Sensor 2 = “);
Serial.print(int(sensor2));
}
}

analogWrite (5, sensor1);
analogWrite (6, sensor2);
}

http://lusorobotica.com/index.php?topic=319.0

Daí gostaria que se alguém tivesse conhecimento melhor sobre o tema me ajudasse!

Exibições: 169

Responder esta

© 2024   Criado por Marcelo Rodrigues.   Ativado por

Badges  |  Relatar um incidente  |  Termos de serviço