summaryrefslogtreecommitdiff
path: root/src/c/scilab-arduino/cmd_i2c_read
diff options
context:
space:
mode:
authorukashanoor2017-06-21 12:15:47 +0530
committerukashanoor2017-06-21 12:15:47 +0530
commit18f7cf96174799b674115e43f108423fa5d0fc9c (patch)
treeab0d0ac7a349986cf95556b7c1975748cbfb8ec1 /src/c/scilab-arduino/cmd_i2c_read
parent785e19f097f7ca1964edaf159c9adfe2eda733b5 (diff)
parente92d6c6791aae06053637ad3bf6b0f9d8986986c (diff)
downloadscilab2c-18f7cf96174799b674115e43f108423fa5d0fc9c.tar.gz
scilab2c-18f7cf96174799b674115e43f108423fa5d0fc9c.tar.bz2
scilab2c-18f7cf96174799b674115e43f108423fa5d0fc9c.zip
updated with main repo
Diffstat (limited to 'src/c/scilab-arduino/cmd_i2c_read')
-rw-r--r--src/c/scilab-arduino/cmd_i2c_read/u8cmd_i2c_reads.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/c/scilab-arduino/cmd_i2c_read/u8cmd_i2c_reads.cpp b/src/c/scilab-arduino/cmd_i2c_read/u8cmd_i2c_reads.cpp
new file mode 100644
index 00000000..8f02a87e
--- /dev/null
+++ b/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);
+
+}