summaryrefslogtreecommitdiff
path: root/src/c/scilab-arduino/cmd_i2c_read
diff options
context:
space:
mode:
authorJorawar Singh2017-06-30 11:54:22 +0530
committerJorawar Singh2017-06-30 11:54:22 +0530
commita7d283ae2899b2530ac70a2453d4db05d03d609d (patch)
treefb93a9edddeee4601c47ce73e173331fa3addac8 /src/c/scilab-arduino/cmd_i2c_read
parentaef4e8398f2b1848b0e4cdd9580dbbe93e4006f9 (diff)
parentbee6bf6e37f6c36fb18b6132702e1528b7edafc2 (diff)
downloadScilab2C_fossee_old-a7d283ae2899b2530ac70a2453d4db05d03d609d.tar.gz
Scilab2C_fossee_old-a7d283ae2899b2530ac70a2453d4db05d03d609d.tar.bz2
Scilab2C_fossee_old-a7d283ae2899b2530ac70a2453d4db05d03d609d.zip
merged main repo with local
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);
+
+}