there are more or less two kinds of Sensors:
Digital Sensors and Analog Sensors
Digital Sensors have two states: ON and OFF. Expressed as a voltage: 5V or 0V.
You connect them to a digital Pin. Set it as input via
And read the current state
value = digitalRead(pin);
Analog Sensors give you a smooth range of values between an minimum and an maximum voltage (0V…5V).
You will connect them to an analog Pins.
And read the current value via
value = analogRead(pin);
There are less and more complex sensors, but they will all fit in either category.
Complex IC-Sensors may require some additional library, simple sensors may require additional circuitry (e.g. pull down resistors)
You can send data from the Arduino and the other way around. That is often an easy way of “debugging” – that is, finding errors.
To do so you have to establish a serial connection in the setup:
Then you can send data to your computer via
If you want dive deeper into the topic and perhaps send data from your computer (or another Arduino) to your Arduino, see for yourself here:
If / Else Constructions
Why does this work?
Examples >> 02. Digital >> StateChangeDetection
Simple Light Sensor
Get a photo cell.
Task: Build a prototype, that will light up a LED, if it gets dark. If it’s get bright again, wait 1s until shutting the LED off.
Solution: Twilight switch
Different applications for one sensor
with a simple light sensor you can build:
Different Sensors for one application?
Light Kinetics by espadaysantacruz studio
Designing a narrative
Make A Wish by espadaysantacruz studio
Task: Come up with a simple machine, that tells an simple, emotional story. A machine, that gets red with anger. That needs a human touch to live…