Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Arduino baslangic dersleri 7
#define Ldr A0
int Isik_siddeti = 0;
void setup()
{
Serial.begin(9600);
for (int i = 2; i < 7; i++)
{
pinMode(i, OUTPUT);
}
}
void loop()
{
int Ldr_deger = analogRead(Ldr);
Isik_siddeti = map (Ldr_deger, 0, 1023, 0, 1000);
Serial.print("ISIK = ");
Serial.println(Isik_siddeti);
if (Isik_siddeti <= 200)
{
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
}
else if (Isik_siddeti > 200 && Isik_siddeti <= 400)
{
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
}
else if (Isik_siddeti > 400 && Isik_siddeti <= 600)
{
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
}
else if (Isik_siddeti > 600 && Isik_siddeti <= 800)
{
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, LOW);
}
else
{
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment