Random Bar Graph.c

Author: Eric Lundby

Simple routine for a Bar Graph Cubelet that will display a random value every __ milliseconds. Supply the VALUE_DURATION to specify for how long the value will displayed.

 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
//Time in milliseconds
#define VALUE_DURATION 200

void setup()
{

}

void loop()
{
    think();
    act();
}

void think()
{
    int r = rand();
    r = r % 256;
    block_value = (uint8_t)r;
    wait(VALUE_DURATION);
}

void act()
{
    set_bar_graph(block_value);
}