31 Dec '14, 3pm

#autopost Creating a Pendulum Monitor with the Wolfram Language and the SparkFun Blocks for Intel Edison #sornram9254

#autopost Creating a Pendulum Monitor with the Wolfram Language and the SparkFun Blocks for Intel Edison #sornram9254

language:c #include "WolframLibrary.h" #include <stdio.h> #include <stdlib.h> #include <sys/stat.h> #include <fcntl.h> #include <sys/ioctl.h> #include <linux/i2c-dev.h> #define UNABLE_TO_OPEN_I2C 128; #define UNABLE_TO_SELECT_DEVICE 129; #define UNABLE_TO_TURN_ON_SENSOR 130; DLLEXPORT int DOF( WolframLibraryData libData, mint Argc, MArgument *Args, MArgument Res) { /* open the i2c device */ int file; file = open( "/dev/i2c-1", O_RDWR ); if( file < 0 ) { return UNABLE_TO_OPEN_I2C; } /* select the device */ int addr = 0x6b; int iores; iores = ioctl( file, I2C_SLAVE, addr); if( iores < 0 ) { return UNABLE_TO_SELECT_DEVICE; } /* make sure the sensor is on */ unsigned char on_command[2] = { 0x20, 0x0f }; if( write(file, on_command, 2) != 2 ) { return UNABLE_TO_TURN_ON_SENSOR; } /* declare variables for reading and writing */ unsigned char buffer[1]; int result; /* set the regis...

Full article: https://www.sparkfun.com/news/1692

Tweets