# Jewel Detector Doll

### The Concept:

This week’s assignment was about combining digital and analog sensors (switch and potentiometer) to control the behavior of at least two LEDs in a creative way. I figured that using more than two LEDs would lead to too many cables on the board so I decided to go with only two LEDs.

To control the two LEDs with analog and digital sensors, I used my doll (which I’m sometimes scared of because it looks too real) as a jewel detector. If you give the doll gold jewelry (or steel or any type of conductor really, but let’s stick to gold vs non-gold for the purpose of the story), the green LED will start blinking. My job as an assistant is to be on guard; if the green light is blinking everything is fine and the jewelry is gold. But if the light is not turning on and I sense suspicious activity, I press the switch and the red LED turns on.

### Code Highlight:

The LED will only blink if the number received from the potentiometer is greater than 500:

```// %%%%%%%%%%%%%%%%%%%%%%%%%%
// convert from 0-1023 proportional to the number of a number of from 0 to 255
if (0 >= inputValue && inputValue <= 500) {
// convert from 0-1023 proportional to the number of a number of from 0 to 255
outputValue = map(inputValue, 0, 500, 0, 255);
}

else if(500 < inputValue && inputValue <= 1023) {
// turn the LED on (HIGH is the voltage level)
digitalWrite(ledPin, HIGH);
// wait for a second
delay(100);
// turn the LED off by making the voltage LOW
digitalWrite(ledPin, LOW);
delay(100);
}
// %%%%%%%%%%%%%%%%%%%%%%%%%%```

### Production:

A short video of how the jewel detector works: