Bluno General Arduino

Bluno Nano - TX/RX not working unless sketch has just been uploaded via USB and Serial Monitor on.

userHead cosmoskebabs 2018-09-01 06:21:46 3320 Views0 Replies
I have been searching for a solution to this problem.

I am using
SKU:DFR0296
and
Arduino IDE 1.8.6 (Settings are Board: Arduino Nano, Processor: ATMega328P)

The sketch works fine if I have just uploaded it to the Bluno via Arduino IDE and Serial Monitor is on.

If I do not have Serial Monitor on or unplug it and attach to a battery pack or even plug it back into the computer it almost works, RX and TX LEDs flash as if it sending and receiving data but the servo and LEDs specified in the code do not operate.

I use an App written in Appinventor to send a string of "1" or "0" to operate the LED and Servo via BLE.

This is the sketch:


----------------------------------------------------------------
#include <Keyboard.h>
#include <Servo.h>
Servo servo_pin_2;

// Bluno Nano, App Inventor 2
//
// Pins
// BT VCC to Arduino 5V out.
// BT GND to GND
// Arduino D8 (ASS RX) - BT TX
// Arduino D9 (ASS TX) - BT RX
// Arduino D4 - Resistor + LED
// Arduino D2 - Servo


byte LEDPin = 4;
char c=' ';

void setup()
{
servo_pin_2.attach(2,530,2600);

Serial.begin(9600);


pinMode(LED_BUILTIN, OUTPUT);
pinMode(LEDPin, OUTPUT);

// testing LEDs and Servo
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);

digitalWrite(LEDPin, HIGH);
delay(1000);
digitalWrite(LEDPin, LOW);
delay(1000);

servo_pin_2.write( 90 );
delay( 2000 );
servo_pin_2.write( 0 );
delay( 2000 );
servo_pin_2.write( 90 );
delay( 2000 );
}



void loop()
{
// Read from the Bluetooth module and turn the LED on and off

if (Serial.available())
{

// The ascii code for 0 is dec 48
// The ascii code for 1 is dec 49
if ( c== 48) { digitalWrite(LED_BUILTIN, LOW);
servo_pin_2.write( 90 );
delay( 250 );
}

if ( c== 49) { digitalWrite(LED_BUILTIN, HIGH);
servo_pin_2.write( 0 );
delay( 250 );

}

if ( c== 48) { digitalWrite(LEDPin, LOW); }
if ( c== 49) { digitalWrite(LEDPin, HIGH); }

c = Serial.read();
Serial.println(c);
}

}


---------------------------------------------------------------------

Is it something to do with DTR / RTS?
Is there a way to set these either HIGH or LOW via arduino sketch code to fix the issue?