johngineer's Oscilloscope Christmas Tree code adjusted for the Particle Photon
This file contains 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
#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