#include #include #include "libschsat.h" #define LSS_OK 0 #define LSS_ERROR 1 #define LSS_BREAK 2 int control(){ // Program’s main function uint16_t sun_result[] = {0, 0, 0}; // Initialize sun_result uint16_t num = 1; // Solar Sensor’s number printf("Enable sun sensor №%d\n", num); sun_sensor_turn_on(num); // Switch on sun sensor Sleep(1); // Wait 1 second for switching on printf("Get RAW data from sun sensor №%d\n", num); int i; for (i = 0; i < 10; i++) //Read the readings 10 times { sun_result[0] = sun_sensor_request_raw(num,& sun_result[1],& sun_result[2]); if (!sun_result[0]){ // if the sensor has not returned 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 has returned error message 1 printf("Fail because of access error, check the connection\n"); } else if (sun_result[0] == 2) { //if the sensor has returned error message 2 printf("Fail because of interface error, check you code\n"); } Sleep(1); //Readings are read one per second } printf("Disable sun sensor №%d\n", num); sun_sensor_turn_off(num); //Switching sun sensor off return 0; }