#include #include #include "libschsat.h" #define LSS_OK 0 #define LSS_ERROR 1 #define LSS_BREAK 2 int control(){ // Main function uint16_t sun_result[] = {0, 0, 0}; // Initializing sun_result uint16_t num = 1; // number of sun sensor printf("Enable sun sensor №%d\n", num); sun_sensor_turn_on(num); // turn the sensor on Sleep(1); // wait 1 second printf("Get RAW data from sun sensor №%d\n", num); int i; for (i = 0; i < 10; i++) // read the sensor 10 times { sun_result[0] = sun_sensor_request_raw(num,& sun_result[1],& sun_result[2]); if (!sun_result[0]){ // if the sensor did not return an error message, printf("state: %d raw = %d, %d\n", i, sun_result[1], sun_result[2]); } else if (sun_result[0] == 1) { // if the sensor did not return an error message 1 printf("Fail because of access error, check the connection\n"); } else if (sun_result[0] == 2) { // if the sensor did not return an error message 2 printf("Fail because of interface error, check you code\n"); } Sleep(1); // wait 1 second } printf("Disable sun sensor №%d\n", num); sun_sensor_turn_off(num); // turn sun sensor off return 0; }