A sensor is a device that measures a physical quantity and converts it into an electric signal. They can be analog (working like potentiometers) or digital (working like switches).
Can you think of some of the sensors you interact with on a daily basis?

From your kit:

Pressure sensor

Replace it with the flex sensor, it should work the same way.
(this circuit has a pushbutton as well, that’s a digital input).


Photocell are basically resistors that change its resistive value (in ohms Ω) depending on how much light is shining onto the squiggly face.
You can use in a laser tripwire.

Hall Effect sensor

This should be a Melexis US1881 latched magnetic sensor with a DIGITAL output. Holding a magnet near the sensor will cause the output pin to toggle LOW or HIGH. Unless the component changed, you’ll probably need to apply an inverse polarity to revert it to the previous state. Imagine two magnets of different polarity on the opposite spokes of a wheel, they can be used to detect the speed.

There are also analog Hall effect sensor as well.
Info and schematics here

Tilt Switch

This works exactly like a switch (DIGITAL INPUT) except it can sense movements, shaking or change of orientation. You have to use pull-up and pull-down resistors and probably a very delayed debounce as well.

Reading analog value to control an analog output.

int LedPin = 11;    // LED connected to analog pin 11
int SensorPin = 0;    // Pot connected to analog pin A0

void setup()  { 

void loop()  { 
  int input = analogRead(SensorPin);

  int output = map(input, 0, 1023, 0, 255);
  analogWrite(LedPin, output);           


The TMP36 is an easy-to-use temperature sensor that outputs a voltage that’s proportional to the ambient temperature.

There are a few conversions you need to do to find the actual temperature they depend on the component.
This is the datasheet of the TMP36

// This formula converts the 0 to 1023 value that analogRead()
// returns, into a 0.0 to 5.0 value that is the true voltage
// being read at that pin.
voltage = analogRead(pin) * 0.004882814;

// Now we'll convert the voltage to degrees Celsius.
// This formula comes from the temperature sensor datasheet:
degreesC = (voltage - 0.5) * 100.0;

// While we're at it, let's convert degrees Celsius to Fahrenheit.
// This is the classic C to F conversion formula:
degreesF = degreesC * (9.0/5.0) + 32.0;

Can you make a “love meter” with LEDs?

Posted in

Post a comment