// LED 핀 정의
// 빨간 10, 노랑 11, 녹색 12
int redled = 10;
int yelled = 11;
int greled = 12;
float current_val = 0.0;
void setup()
{
pinMode(redled,OUTPUT); pinMode(yelled, OUTPUT); pinMode(greled,OUTPUT);
}
void loop()
{
int raw_val = analogRead(A0);
// raw_val >> current_val (변환공식)
current_val = raw_val * 0.1;
if(current_val > 10) //mA
{
digitalWrite(yelled,HIGH);
}
else
{
digitalWrite(yelled,LOW); digitalWrite(greled,HIGH);
}
}