From ef2a04cd46ee49c13b7d2af95e3d35fcc7c7d756 Mon Sep 17 00:00:00 2001 From: Clemens Fries Date: Sun, 16 Sep 2018 00:52:55 +0200 Subject: added code for tiny clay house project --- lighting/tinyhouse.ino | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 lighting/tinyhouse.ino (limited to 'lighting') diff --git a/lighting/tinyhouse.ino b/lighting/tinyhouse.ino new file mode 100644 index 0000000..f2bf4f8 --- /dev/null +++ b/lighting/tinyhouse.ino @@ -0,0 +1,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; +} -- cgit