diff options
author | Ankit Raj | 2017-06-21 11:42:02 +0530 |
---|---|---|
committer | Ankit Raj | 2017-06-21 11:42:02 +0530 |
commit | 56aa185002761d966abebb5c67e6c1a2d5ee141c (patch) | |
tree | 828d1fb53c63bd707798807b33667b56a43eda49 /2.3-1/src/c/scilab-arduino/cmd_i2c_read | |
parent | b96df0699b8aa17e7ba43ebafca5a557b9acebf5 (diff) | |
parent | 0051253bc224286c118c080c79eaed5bf611bd35 (diff) | |
download | Scilab2C-56aa185002761d966abebb5c67e6c1a2d5ee141c.tar.gz Scilab2C-56aa185002761d966abebb5c67e6c1a2d5ee141c.tar.bz2 Scilab2C-56aa185002761d966abebb5c67e6c1a2d5ee141c.zip |
updated with main repo
Diffstat (limited to '2.3-1/src/c/scilab-arduino/cmd_i2c_read')
-rw-r--r-- | 2.3-1/src/c/scilab-arduino/cmd_i2c_read/u8cmd_i2c_reads.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/2.3-1/src/c/scilab-arduino/cmd_i2c_read/u8cmd_i2c_reads.cpp b/2.3-1/src/c/scilab-arduino/cmd_i2c_read/u8cmd_i2c_reads.cpp new file mode 100644 index 00000000..8f02a87e --- /dev/null +++ b/2.3-1/src/c/scilab-arduino/cmd_i2c_read/u8cmd_i2c_reads.cpp @@ -0,0 +1,18 @@ +#include "cmd_i2c_read.h" +#include "Arduino.h" +#include "Wire.h" + +float u8cmd_i2c_reads(uint8 address, uint8 bytes) +{ + + float c; //variable declaration to save received data + + // request reading from sensor + Wire.requestFrom(address, bytes); // request no. of bytes(given) from slave device with address + + // receive reading from sensor + while (Wire.available()) //If data is received + c = Wire.read(); //Save received data in variable + return(c); + +} |