aboutsummaryrefslogtreecommitdiffstats
path: root/lighting/tinyhouse.ino
blob: f2bf4f8bd3d2462634c7383992a30b0e2149dd17 (plain)
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
void setup() {
  pinMode(3, OUTPUT);
  pinMode(5, OUTPUT);
}

int i = 127;
int j = 127;

void loop() {
  delay(50);

  i = limit(i + (random(2) == 0 ? 8 : -8), 16);
  j = limit(j + (random(2) == 0 ? 2 : -2),  2);

  analogWrite(3, j);
  analogWrite(5, i);

}

int limit(int i, int within) {
  if( i > (255 - within) )
    return 255 - within;

  if( i < within )
    return within;

  return i;
}