Ult
Projects
Urt
Ll Lr

Ult
Featured
Urt
Ll Lr

Ult
Log in
Urt
Ll Lr


Randomrectanglescropped_small
Digg_16x16 Delicious_16x16 Reddit_16x16 Technorati_16x16 Blinklist_16x16 Furl_16x16
2 images, 1 part

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 */
}

0 Comments on Random Rectangles



Add A Comment:

Get in touch if you have any questions, or ideas for something you want me to build.