Created
January 5, 2022 17:35
-
-
Save Park-Developer/4700809c40cad2f1727e26a649b3471c to your computer and use it in GitHub Desktop.
RPI : IR + ADC test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <wiringPi.h> | |
#include <pcf8591.h> | |
#include <math.h> | |
#define PCF 120 | |
int main (void) | |
{ | |
int value0 ; | |
int value1; | |
wiringPiSetup () ; | |
// Setup pcf8591 on base pin 120, and address 0x48 | |
pcf8591Setup (PCF, 0x48) ; | |
while(1) // loop forever | |
{ | |
value0 = analogRead (PCF + 0) ; | |
value1 = analogRead (PCF + 1) ; | |
printf("volt : %f , dist : %lf\n" , value0*3.3/256,pow((value0*3.3/256),-1.173)*29.988); | |
//printf("A1 %d\n", value1); | |
//analogWrite (PCF + 0, value) ; | |
delay (100) ; | |
} | |
return 0 ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment