Загрузка данных


#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

Adafruit_SSD1306 display(128, 64, &Wire, -1);

#define LEFT_LDR A3
#define BOTTOM_LDR A1
#define RIGHT_LDR A2
#define LED 12

#define MIN_VALUE 700

void setup() {
   display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
   pinMode(LED, OUTPUT);
}

void loop() {
   bool left_triggered = getLux(analogRead(LEFT_LDR)) > MIN_VALUE;
   bool right_triggered = getLux(analogRead(RIGHT_LDR)) > MIN_VALUE;
   bool bottom_triggered = getLux(analogRead(BOTTOM_LDR)) > MIN_VALUE;

   int triggered_count = left_triggered + right_triggered + bottom_triggered;
   blink(triggered_count);

   if (triggered_count == 3) {
       /* your_answer */;
   }
   else if (triggered_count == 2) {
       if (left_triggered && right_triggered) {
           /* your_answer */;
       }
       else if (left_triggered && bottom_triggered) {
           printText("Light - 1 3");
       }
       else if (// Подзадача 1.3 && bottom_triggered) {
           printText("Light - 2 3");
       }
   }
   else if (/* your_answer */) {
       if (left_triggered) {
           /* your_answer */;
       }
       else if (right_triggered) {
           /* your_answer */;
       }
       else if (bottom_triggered) {
           printText("Light - 3");
       }
   } else {
       /* your_answer */;
   }
   delay(5);
}

void blink(int count) {
   // Подзадача 1.2
}

void printText(const char* text) {
   display.clearDisplay();
   display.setTextSize(1);
   display.setTextColor(SSD1306_WHITE);
   display.setCursor(15, 28);
   display.println(text);
   display.display();
}

float getLux(int adc) {
   constexpr float R1 = 127410.0f;
   constexpr float GAMMA = 0.8582f;
   constexpr float R_FIXED = 10000.0f;
  
   float rLdr = R_FIXED * (1023.0f / adc - 1.0f);
   float lux = pow(R1 / rLdr, 1.0f / GAMMA);
  
   return lux;
}