summaryrefslogtreecommitdiff
path: root/src/c/scilab-arduino/cmd_i2c_read
diff options
context:
space:
mode:
authorAnkit Raj2017-06-21 11:42:02 +0530
committerAnkit Raj2017-06-21 11:42:02 +0530
commit061f07929cc984788154bc296c6cc440ef72a3c6 (patch)
treec486321ca7a986cb0ffe9c1c8c5f9c385a697776 /src/c/scilab-arduino/cmd_i2c_read
parentec8943082d8c262485e7b34515b1597b1d887867 (diff)
parente92d6c6791aae06053637ad3bf6b0f9d8986986c (diff)
downloadScilab2C_fossee_old-061f07929cc984788154bc296c6cc440ef72a3c6.tar.gz
Scilab2C_fossee_old-061f07929cc984788154bc296c6cc440ef72a3c6.tar.bz2
Scilab2C_fossee_old-061f07929cc984788154bc296c6cc440ef72a3c6.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 0000000..8f02a87
--- /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);
+
+}