Hi,
I am working on a project using Arduino Nano, where I have to receive some serial data (characters) from a serial console of a device and enable a few pins on digital o/p based on kind of characters I receive. For now I have also enabled pin 13 to make LED glow when serial data is received. I want to use pin 1,2 for the serial Tx/Rx operation.
I have written a small piece of code, where I blink the LED on pin 13 if I receive any serial data. For powering the Nano I am using mini-USB connected to my PC (I am not sure if that is causing the problem)
#include <SoftwareSerial.h>
//int A=0;
unsigned int D2=2;
unsigned int D1=1;
unsigned int J1=5;
unsigned int J2=6;
unsigned int J3=7;
unsigned int J4=8;
unsigned int LED1=13; //pin 13 is LED
SoftwareSerial port(D1,D2);
void setup()
{
pinMode(D2, INPUT);
pinMode(D1, OUTPUT);
pinMode(J1, OUTPUT);
pinMode(J2, OUTPUT);
pinMode(J3, OUTPUT);
pinMode(J4, OUTPUT);
pinMode(LED1, OUTPUT);
Serial.begin(19200);
port.begin(19200);
}
void loop()
{
if ( port.available()>0 )
{
digitalWrite(LED1, HIGH);
delay(2000);
digitalWrite(LED1, LOW);
delay(2000);
}
but, when I am sending some serial data to the Rx of Arduino I am not able to see LED blinking. Please help !!
Thanks !