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


#include <Servo.h>

Servo arm; // Create a "Servo" object called "arm"
float pos = 0.0; // Variable where the arm's position will be stored (in degrees)
float step = 1.0; // Variable used for the arm's position step
  float bebra = 0;
const float GAMMA = 0.7;
const float RL10 = 50;

void setup()
{
  pinMode(A0, INPUT); // Set the A1 pin to a pushbutton in pullup mode
  arm.attach(3); // Attache the arm to the pin 2
  arm.write(pos); // Initialize the arm's position to 0 (leftmost)
}

void loop()
{
  int analogValue = analogRead(A0);
  float voltage = analogValue / 1024. * 5;
  float resistance = 2000 * voltage / (1 - voltage / 5);
  float lux = pow(RL10 * 1e3 * pow(10, GAMMA) / resistance, (1 / GAMMA));

  // lux = map(lux, 0, 200, 0, 180);     // scale it to use it with the servo (value between 0 and 180)


  if (lux < 500) // Check for the yellow button input
  {
    bebra = 0;
  }
  if (lux < 1000, 500 < lux) // Check for the yellow button input
  {
    bebra = 90;
  }
  if (lux > 1000 )
  {
    bebra = 180;
  }
  arm.write(bebra);                  // sets the servo position according to the scaled value
  delay(15);                           // waits for the servo to get there
}