Last active
May 29, 2020 19:24
-
-
Save bboyho/554cdcdac422a8cf07f4f2d870120d38 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/****************************************************************************** | |
Simple Serial Test of the Sparkun nRF52840 Mini Bluetooth Development Board | |
Written by: Ho Yun "Bobby" Chan | |
@ SparkFun Electronics | |
Date: May 29, 2020 | |
Description: This sketch sets up the built-in LED, native USB | |
serial port, and hardware serial pins. The nRF52840 will print | |
a message based on the status of the LED to both the Arduino | |
serial monitor using `Serial` and the hardware serial pins | |
using `Serial1`. Any characters sent from an FTDI to the | |
hardware serial pins will display in the Arduino serial monitor. | |
This was written to test out an issue: | |
https://github.com/sparkfun/nRF52840_Breakout_MDBT50Q/issues/7 | |
========== HARDWARE CONNECTIONS ========== | |
Make sure to grab 3x wires and connect it to an USB-to-Serial converter | |
like an FTDI. | |
nRF52840 Mini <-> FTDI | |
---------------------- | |
GND <-> GND | |
TX (17) <-> RX | |
RX (15) <-> TX | |
========== RESOURCES/LIBRARIES ========== | |
You will need to make sure to add the Arduino Core files for the nRF52 | |
and include the board definitions as outlined in: | |
https://learn.sparkfun.com/tutorials/nrf52840-development-with-arduino-and-circuitpython#arduino-installation | |
This has been tested with the Adafruit_nRF52_Arduino core v0.16.0 and v0.20.1 releases. | |
Development Environment Specifics: | |
Arduino 1.8.10+ | |
License: | |
This code is released under the MIT License (http://opensource.org/licenses/MIT) | |
Distributed as-is; no warranty is given. | |
******************************************************************************/ | |
// Define hardware: LED pins and states | |
const int LED_PIN = 7; | |
#define LED_OFF LOW | |
#define LED_ON HIGH | |
void setup() { | |
// Serial is the native USB Serial Port, i.e. Arduino Serial Monitor | |
Serial.begin(9600); | |
// Serial1 is the Hardware UART Pins | |
Serial1.begin(9600); | |
// Initialize hardware: | |
pinMode(LED_PIN, OUTPUT); // Turn on-board blue LED off | |
digitalWrite(LED_PIN, LED_OFF); | |
} | |
void loop() { | |
if (Serial1.available()) { | |
//If we receive data from the Hardware UART pins, we | |
//pass data received from hardware uart to the | |
//native USB Serial Port (i.e. Arduino Serial Monitor). | |
Serial.print("Character received = "); | |
Serial.write(Serial1.read()); | |
Serial.println(""); | |
} | |
//Send serial data to native USB Serial Port | |
Serial.println("LED ON!!!"); | |
//Send serial data out of hardware UART pins | |
Serial1.println("Hello FTDI! Just letting you know, the LED is ON!!!"); | |
digitalWrite(LED_PIN, LED_ON); | |
delay(50); | |
//Send serial data to native USB Serial Port | |
Serial.println("LED off..."); | |
//Send serial data out of hardware UART pins | |
Serial1.println("Hello FTDI! Just letting you know, the LED is off..."); | |
digitalWrite(LED_PIN, LED_OFF); | |
delay(50); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment