diff options
author | Clemens Fries <git-arduino@xenoworld.de> | 2018-09-16 00:52:55 +0200 |
---|---|---|
committer | Clemens Fries <git-arduino@xenoworld.de> | 2018-09-16 00:52:55 +0200 |
commit | ef2a04cd46ee49c13b7d2af95e3d35fcc7c7d756 (patch) | |
tree | da638b54f3499fa55e9b5bb10a59f96017521190 | |
parent | b41eb69e25f9586ab41f8175ccaaff8fdde4e9a4 (diff) |
added code for tiny clay house project
-rw-r--r-- | README.adoc | 9 | ||||
-rw-r--r-- | lighting/tinyhouse.ino | 28 |
2 files changed, 36 insertions, 1 deletions
diff --git a/README.adoc b/README.adoc index 698e25a..c7de3c6 100644 --- a/README.adoc +++ b/README.adoc @@ -4,10 +4,17 @@ Every now and then I create a small Arduino (test) project. I think I should publish the stuff here — this is mostly cargo cult code that has been hammered into some semi-working form. -=== lighting/strobe.ino +=== lighting/ + +==== strobe.ino The code behind my https://xenoworld.de/2017/01/18/blink.html[fluorescent light demo]. +=== tinyhouse.ino + +Quick hack for some soothing orange light put into a tiny desk-top house made +of clay + === humidity-led-indicator/ Code for a small project which uses a humidity sensor (DHT22) and an 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; +} |