Devices & Components
Arduino Uno Rev3
Jumper wires (generic)
SparkFun USB to Serial Breakout - FT232RL
Hardware & Tools
Soldering iron (generic)
Solder Wire, Lead Free
Software & Tools
Visual Micro
Visual Studio 2017
Arduino IDE
Project description
Code
GDBStubExample.ino
arduino
Main GDBStub Sketch Example used in this tutorial
1#ifdef _DEBUG 2#include <SoftwareSerial.h> 3#include <avr8-stub.h> 4#include <app_api.h> 5 6 #define USE_SERIAL SWSerial 7 SoftwareSerial SWSerial(2, 3); 8#else 9 #define USE_SERIAL Serial 10#endif 11 12double currentSinVal = 0.0; 13double currentCosVal = 0.0; 14int randomVal = 0; 15 16 17 18void setup() { 19#ifdef _DEBUG 20 debug_init(); 21#endif 22 23 USE_SERIAL.begin(115200); 24 25 randomSeed(millis()); 26} 27 28void loop() { 29#ifdef _DEBUG 30 breakpoint(); 31#endif 32 currentSinVal = getSinValue(millis()); 33 currentCosVal = getCosValue(millis()); 34 randomVal += random(0, 100); 35 36 USE_SERIAL.println(randomVal); 37 38} 39
Calcs.ino
arduino
Secondary code file used in examples
1 2double getSinValue(unsigned long millis) { 3 double newSin = 1+ sin(millis / 200); 4 return newSin * 90; 5} 6 7double getCosValue(unsigned long millis) { 8 double newCos = cos(millis / 200); 9 return newCos * 90; 10}
GDBStubExample.ino
arduino
Main GDBStub Sketch Example used in this tutorial
1#ifdef _DEBUG 2#include <SoftwareSerial.h> 3#include <avr8-stub.h> 4#include <app_api.h> 5 6 #define USE_SERIAL SWSerial 7 SoftwareSerial SWSerial(2, 3); 8#else 9 #define USE_SERIAL Serial 10#endif 11 12double currentSinVal = 0.0; 13double currentCosVal = 0.0; 14int randomVal = 0; 15 16 17 18void setup() { 19#ifdef _DEBUG 20 debug_init(); 21#endif 22 23 USE_SERIAL.begin(115200); 24 25 randomSeed(millis()); 26} 27 28void loop() { 29#ifdef _DEBUG 30 breakpoint(); 31#endif 32 currentSinVal = getSinValue(millis()); 33 currentCosVal = getCosValue(millis()); 34 randomVal += random(0, 100); 35 36 USE_SERIAL.println(randomVal); 37 38} 39
Downloadable files
Uno to USB Serial Breakout Wiring
Shows how to wire a USB Serial converter to the Uno for this example.
Uno to USB Serial Breakout Wiring

Uno to USB Serial Breakout Wiring
Shows how to wire a USB Serial converter to the Uno for this example.
Uno to USB Serial Breakout Wiring

Comments
Only logged in users can leave comments