Created
November 20, 2016 07:01
-
-
Save jinfeijie/957443069b3461df8c16cf5ecfe653a5 to your computer and use it in GitHub Desktop.
温度传感器
This file contains hidden or 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
int pin = A1; | |
int tempc = 0; | |
int samples[8]; | |
int maxi = -100,mini = 100; | |
int i; | |
void setup(){ | |
pinMode(pin,INPUT); | |
} | |
void loop(){ | |
for(i = 0;i<=7;i++) | |
{ | |
samples[i] = ( 5.0 * analogRead(pin) * 100.0) / 1024.0; | |
tempc = tempc + samples[i]; | |
delay(100); | |
} | |
tempc = tempc/8.0; | |
printf("%d\n",tempc); | |
delay(100); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment