diff options
author | Philip Lampkin <plampkin@chem.wisc.edu> | 2021-03-01 14:52:25 -0600 |
---|---|---|
committer | Philip Lampkin <plampkin@chem.wisc.edu> | 2021-03-01 14:52:25 -0600 |
commit | c638cb47f8a4c173f8f226ea4ba85c6ec08bdec1 (patch) | |
tree | 8fc5a635c722e0206647a3a0d8d4e259264aa6e8 /digital-controller/firmware | |
parent | 6c3a55f379230d190a1b9030dea27fb8b08b3cbf (diff) | |
parent | b6f7e9ed64c93ef06c50291cedadb73c1b1fd1dc (diff) |
philip march first
Diffstat (limited to 'digital-controller/firmware')
-rw-r--r-- | digital-controller/firmware/firmware.ino | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/digital-controller/firmware/firmware.ino b/digital-controller/firmware/firmware.ino new file mode 100644 index 0000000..86e4bb0 --- /dev/null +++ b/digital-controller/firmware/firmware.ino @@ -0,0 +1,36 @@ +#include <Wire.h> + +#define I2C_SLAVE_ADDR 0x26 // I2C slave address (38, 0x26) + +void setup() +{ + // init the Wire object + Wire.begin(); + + // wait for slave to finish any init sequence + delay(2000); +} + +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. + + // 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); + } +} |