aboutsummaryrefslogtreecommitdiff
path: root/digital-controller/arduino-uno-controller/firmware
diff options
context:
space:
mode:
authorBlaise Thompson <blaise@untzag.com>2021-04-24 16:55:25 -0500
committerGitHub <noreply@github.com>2021-04-24 16:55:25 -0500
commite9975e2b16f095f2a92946e76af5343b98e76ccc (patch)
treee225b14cba263ce466e6f4ded30de7e2cbe8857d /digital-controller/arduino-uno-controller/firmware
parentc42f09af60f1a984078a9806eb48afce5fe85b2c (diff)
parent871f3f9ebe774e12ba870eedd2409ee9af6a6189 (diff)
Merge pull request #4 from plampkin/terminology
Updated terminology, add additional descriptions, updated graphics
Diffstat (limited to 'digital-controller/arduino-uno-controller/firmware')
-rw-r--r--digital-controller/arduino-uno-controller/firmware/firmware.ino41
1 files changed, 41 insertions, 0 deletions
diff --git a/digital-controller/arduino-uno-controller/firmware/firmware.ino b/digital-controller/arduino-uno-controller/firmware/firmware.ino
new file mode 100644
index 0000000..e87db8d
--- /dev/null
+++ b/digital-controller/arduino-uno-controller/firmware/firmware.ino
@@ -0,0 +1,41 @@
+#include <Wire.h>
+
+#define I2C_SLAVE_ADDR 0x26 // I2C slave address (38, 0x26)
+
+void setup()
+{
+ pinMode(A4, OUTPUT);
+ pinMode(A5, OUTPUT);
+ // init the Wire object
+ Wire.begin();
+
+ // wait for slave to finish any init sequence
+ delay(2000);
+
+ Serial.begin(9600);
+}
+
+void loop()
+{
+ for( int a=10; a<=255; a++ ){
+ //generate buffer containing data to send via I2C
+ uint8_t buf[1];
+ buf[0] = 255-a; // adjusting this byte changes fan speed. Can be adjusted from 0 to 256.
+ buf[1] = a; // adjusting this byte changes LED intensity. Can be adjusted from 0 to 256.
+ Serial.println(int(buf));
+
+ // send buffer
+ Wire.beginTransmission(I2C_SLAVE_ADDR);
+ Wire.write(buf, 2);
+ Wire.endTransmission();
+
+ // delay 20 milliseconds to accomodate slave onReceive()
+ delay(20);
+
+ /////////////////////// WHY DO I NEED THIS PART?//////////////////////////
+ Wire.requestFrom(I2C_SLAVE_ADDR, 1);
+
+ // delay 1 second so user can watch results
+ delay(50);
+ }
+}