Skip to content

Instantly share code, notes, and snippets.

@kevinl95
Last active December 6, 2017 03:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinl95/db24c539f94518eeea8fb6e83156b2ab to your computer and use it in GitHub Desktop.
Save kevinl95/db24c539f94518eeea8fb6e83156b2ab to your computer and use it in GitHub Desktop.
johngineer's Oscilloscope Christmas Tree code adjusted for the Particle Photon
#define TRACE_DELAY 15000 // trace delay in uS. making this longer will
// result in a straighter drawing, but slower
// refresh rate. making it too short will result
// in an angular blob.
#define NUM_POINTS 19 // our tree is defined by 19 x/y coord. pairs
#define X D0 // attach scope channel 1 (X)
#define Y D1 // attach scope channel 2 (y)
// x coords for drawing the tree (in rough clockwise order, from bottom)
unsigned char x_points[NUM_POINTS] = { 110, 110, 50, 80, 65, 95, 80, 110, 95, 125,
155, 140, 170, 155, 185, 170, 200, 140, 140 };
// y coords
unsigned char y_points[NUM_POINTS] = { 15, 35, 35, 85, 85, 135, 135, 185, 185, 235,
185, 185, 135, 135, 85, 85, 35, 35, 15 };
void setup()
{
pinMode(X, OUTPUT);
pinMode(Y, OUTPUT);
//analogWriteResolution(X, 234);
//analogWriteResolution(Y, 234);
}
void loop()
{
unsigned char t;
{
for(t = 0; t < NUM_POINTS; t++) // run through the points in x & y
{
analogWrite(X, x_points[t]);
analogWrite(Y, y_points[t]);
delayMicroseconds(TRACE_DELAY); // wait TRACE_DELAY microseconds
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment