|
| 1 | +/* Pro Micro Test Code |
| 2 | + by: Nathan Seidle |
| 3 | + modified by: Jim Lindblom |
| 4 | + SparkFun Electronics |
| 5 | + date: September 16, 2013 |
| 6 | + license: Public Domain - please use this code however you'd like. |
| 7 | + It's provided as a learning tool. |
| 8 | +
|
| 9 | + This code is provided to show how to control the SparkFun |
| 10 | + ProMicro's TX and RX LEDs within a sketch. It also serves |
| 11 | + to explain the difference between Serial.print() and |
| 12 | + Serial1.print(). |
| 13 | +*/ |
| 14 | + |
| 15 | +int RXLED = 17; // The RX LED has a defined Arduino pin |
| 16 | +// The TX LED was not so lucky, we'll need to use pre-defined |
| 17 | +// macros (TXLED1, TXLED0) to control that. |
| 18 | +// (We could use the same macros for the RX LED too -- RXLED1, |
| 19 | +// and RXLED0.) |
| 20 | + |
| 21 | +void setup() |
| 22 | +{ |
| 23 | + pinMode(RXLED, OUTPUT); // Set RX LED as an output |
| 24 | + // TX LED is set as an output behind the scenes |
| 25 | + |
| 26 | + Serial.begin(9600); //This pipes to the serial monitor |
| 27 | + Serial1.begin(9600); //This is the UART, pipes to sensors attached to board |
| 28 | +} |
| 29 | + |
| 30 | +void loop() |
| 31 | +{ |
| 32 | + Serial.println("Hello world"); // Print "Hello World" to the Serial Monitor |
| 33 | + Serial1.println("Hello!"); // Print "Hello!" over hardware UART |
| 34 | + |
| 35 | + digitalWrite(RXLED, LOW); // set the RX LED ON |
| 36 | + TXLED0; //TX LED is not tied to a normally controlled pin so a macro is needed, turn LED OFF |
| 37 | + delay(1000); // wait for a second |
| 38 | + |
| 39 | + digitalWrite(RXLED, HIGH); // set the RX LED OFF |
| 40 | + TXLED1; //TX LED macro to turn LED ON |
| 41 | + delay(1000); // wait for a second |
| 42 | +} |
0 commit comments