Advertisement
Guest User

Untitled

a guest
Jan 10th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.45 KB | None | 0 0
  1. #include <wiringPi.h>
  2. #include <stdio.h>
  3. #include <unistd.h>
  4. #define N 2
  5. int main (void)
  6. {
  7.     wiringPiSetup();
  8.     pinMode(1,OUTPUT);
  9.     int temp;
  10.     char arr[N];
  11.     FILE *file;
  12.     while(1){
  13.         file = fopen("/sys/class/thermal/thermal_zone0/temp","r");
  14.         fgets(arr,4,file);
  15.         fclose(file);
  16.         temp=(arr[0]-'0')*10+arr[1]-'0';
  17.         printf("%i\n",temp);
  18.         if(temp>55)
  19.             digitalWrite(1,HIGH);
  20.         else
  21.             digitalWrite(1,LOW);
  22.         delay(10000);
  23.     }
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement