summaryrefslogtreecommitdiff
path: root/src/c/scilab-arduino/cmd_i2c_read/u8cmd_i2c_reads.cpp
blob: 8f02a87e3cc5533340b3a7178a74f9ae9e776b04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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);
	
}