//LK-5 LED DAN POTENSIOMETER
//AHMAD MUKHLIS ANSHORI
//SMAN 2 PONOROGO
//DIDAMBA ANGKATAN 15
int pinsensor = A0;
int ledmerah = 13;
int ledkuning = 12;
int ledhijau = 11;
int nilaisensor;

void setup() {
  Serial.begin(9600);
  Serial.println("LED DAN POTENSIOMETER");
  Serial.println("AHMAD MUKHLIS ANSHORI");
  pinMode(pinsensor, INPUT);
  pinMode(ledmerah, OUTPUT);
  pinMode(ledkuning, OUTPUT);
  pinMode(ledhijau, OUTPUT);
  }

void loop() {
  nilaisensor= analogRead(pinsensor);
  Serial.println(nilaisensor);

  //LED MERAH
  analogWrite(ledmerah, nilaisensor);

  //LED KUNING
  if(nilaisensor >=200 && nilaisensor < 600)
  {
  digitalWrite(ledkuning, HIGH);
  delay(nilaisensor);
  digitalWrite(ledkuning, LOW);
  delay(nilaisensor);
  }
  if(nilaisensor>1000)
  {
  digitalWrite(ledkuning, HIGH);
  }
  else
  digitalWrite(ledkuning, LOW);
 
 //LED HIJAU
  digitalWrite(ledhijau, HIGH);
  delay(nilaisensor);
  digitalWrite(ledhijau, LOW);
  delay(nilaisensor);
 
}