Skip to content

Instantly share code, notes, and snippets.

@sjfricke
Created March 4, 2018 01:28
Show Gist options
  • Select an option

  • Save sjfricke/ed16abc52ee91d681688a78c89832c2b to your computer and use it in GitHub Desktop.

Select an option

Save sjfricke/ed16abc52ee91d681688a78c89832c2b to your computer and use it in GitHub Desktop.
ads1115 demo test
// gcc test.c -lwiringPi -o test
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <wiringPi.h>
#include <ads1115.h>
#define MY_BASE 2222
#define JOY_RX 0
#define JOY_RY 1
#define POT 2
#define TEMPERATURE 3
int main ( int argc, char* argv[] ) {
int joy_x, joy_y, pot_val, temp_val;
// sets up the wiringPi library
if (wiringPiSetupGpio () < 0) {
puts("ERROR SETTING UP");
return 1;
}
ads1115Setup (MY_BASE, 0x48);
while(1) {
joy_x = analogRead (MY_BASE + JOY_RX);
joy_y = analogRead (MY_BASE + JOY_RY);
pot_val = analogRead (MY_BASE + POT);
temp_val = analogRead (MY_BASE + TEMPERATURE);
printf("joy_x: %d\tjoy_y: %d\npot_val: %d\ntemp_val: %d\n", joy_x, joy_y, pot_val, temp_val);
sleep(1);
}
@Lauro199471
Copy link
Copy Markdown

Amazing work! Got this working with ROS as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment