Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <wiringPi.h>
- #include <stdio.h>
- #include <unistd.h>
- #define N 2
- int main (void)
- {
- wiringPiSetup();
- pinMode(1,OUTPUT);
- int temp;
- char arr[N];
- FILE *file;
- while(1){
- file = fopen("/sys/class/thermal/thermal_zone0/temp","r");
- fgets(arr,4,file);
- fclose(file);
- temp=(arr[0]-'0')*10+arr[1]-'0';
- printf("%i\n",temp);
- if(temp>55)
- digitalWrite(1,HIGH);
- else
- digitalWrite(1,LOW);
- delay(10000);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement