Random Rectangles
Here is a quick demo of the random function added to the TouchShield core.
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 */ } |
7 Comments on Random Rectangles
Are the touch shield products also open source? Are schematics, etc available for them? It seems that this product has a lot more capability than is apparent right now….
In Arduino 0017 this piece of code says
error: ‘COLOR’ does not name a type In function ‘void setup()’:
what am I doing wrong .. are there updates to how you code in this latest version?
hmm just stumbled upon the Antipasto Arduino IDE .. is that the answer? I am trying it now ..
well … the ide gives me java errors on snow leopard .. any chances we can plug the libraries in the newer arduino builds?
What was your java error? The antipasto ide is the right direction… What operating system are you using?
Mac OSX 10.6.1 The error is :
Cannot launch Java application
Uncaught exception in main method: java.lang.UnsatisfiedLinkError: /Applications/Arduino/Arduino.app/Contents/Resources/Java/librxtxSerial.jnilib: no suitable image found. Did find: /Applications/Arduino/Arduino.app/Contents/Resources/Java/librxtxSerial.jnilib: no matching architecture in universal wrapper
I was receiving a similar error with the arduino standalone app, but they released the new version 0017 and fixed it ..







I’ve had my Arduino and Stealth for about 5 days now. Things are going quite well, but it seems two things have come up that I’d like to toss out for updates to the blog/docs.
1. The touch core on this website is not correct. I’m using Arduino-0013. I yanked the cores out of the liquidware Arduino-0012 distribution, updated my boards.txt – and I was off to the races.
2. Most of the sketches on this website appear to be maybe for another or older core/API. It’s not anything too big, but I seem to have to clean up every example I try.
(Note – this is not a complaint. I was expected to do some hacking when I got started on this…. These comments are just to help others out a little.)