Random Rectangles
Here is a quick demo of the random function added to the TouchShield core.
Parts for Random Rectangles:
For reference, the new functions prototypes are,
1 2 3 4 5 |
long random(long); long random(long, long); void randomSeed(unsigned int); long map(long, long, long, long, long); |

TouchShield Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
/* Random Bars */ /* Chris Ladden */ COLOR c = {10,10,255}; uint8_t x, yValue; void setup() { /* Make 25 bars */ for (x=0; x<25; x++) { /* Generate a random brighter color */ c.red = random(100,255); c.green = random(100,255); c.blue = random(100,255); /* Generate a random height */ yValue = random(10,120); /* Draw the rectangle */ lcd_rectangle(x*5, yValue, x*5+3, 127, c, c); } } void loop() { /* Do nothing, just look pretty */ } |






