Pessoal, me ajuda aí por favor?
Estou começando a trabalhar com o arduíno e estou tentando fazer funcionar o APC220.
Montei a confguração que está nesse link Wireless Arduino – SwanRobotics
A unica diferença é que estou utilizando o arduíno Mega ao invés do UNO.
Utilizando o RF-ANET para testar a comunicação (o drive está instalado corretamente) estou utilizando a porta COM8 para o APC220, ele encontra o módulo normalmente.
O problema é quando tento fazer o upload do código para o arduíno Mega. O status fica 'Uploading...' eternamente, e o LED de TX fica aceso constantemente sem nem mesmo piscar, ou seja, não grava (ou pelo menos acho que não).
Quando estou gravando estou desconectando o APC220 do meu PC e selecionando a porta COM7 (que está configurada para o ATMEGA128 do arduino Mega).
Alguém tem idéia do que possa estar acontecendo?
Testei os dois módulos APC220 no PC com o RF-ANET sem problemas.
Já reiniciei o PC, tentei com outro PC, executei o Arduíno como administrador.. nada resolveu..
Também testei outro código e aconteceu o mesmo problema. Vou colocar os 2 códigos que tentei abaixo:
Primeiro Código:
// set pins:
const int switchPin = 3; // pin number of the switch
const int ledPin = 2; // pin number of the LED
// variables:
int switchState = 0; // variable for reading switch status
int intSerialVal = 0; // variable for reading Serial Value
// initialize
void setup() {
// initialize LED pin as output:
pinMode(ledPin, OUTPUT);
// initialize switch pin as input:
pinMode(switchPin, INPUT);
// initialize serial wireless communication:
Serial.begin(9600);
// read initial state of switch
switchState = digitalRead(switchPin);
}
// program loop
void loop()
{
// LED control
intSerialVal = Serial.read(); // read user input
switch (intSerialVal) {
case '0':
digitalWrite(ledPin,LOW); // turn LED off
Serial.println("Led Off"); // send message about LED
break;
case '1':
digitalWrite(ledPin,HIGH); // turn LED on
Serial.println("Led On"); // send message about LED
break;
}
// read switch state and print line if state has changed
switch (digitalRead(switchPin)) { // read pin status
case HIGH:
if (switchState == LOW) { // check if message has to be send
Serial.println("Switch On"); // send message about switch
switchState = HIGH; // message has been send
}
break;
case LOW:
if (switchState == HIGH) { // check if message has to be send
Serial.println("Switch Off"); // send message about switch
switchState = LOW; // message has been send
}
break;
}
}
Segundo Código
int val = 0;
int ledPin = 13;
void setup()
{
Serial.begin(9600);
}
void loop()
{
val = Serial.read();
if (-1 != val) {
if ('A' == val || 'a' == val) {
Serial.println("Hello from Arduino!");
}else if ('B' == val || 'b' == val) {
digitalWrite(ledPin, HIGH);
delay(2000);
digitalWrite(ledPin, LOW);
}
}
}
Desde já agradeço pela ajuda!!