Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Embedded systems and sensors Lennart Herlaar Part 2 Interaction technology 1 Contents • Sensors and actuators • Coding and sketches • Circuits • Pull-up resistors • Voltage dividers Sensors and actuators Sensors and actuators • Sensors sense the world around us • From a physical property to a digital value • Actuators manipulate the world around us • From a digital value to a physical property • Type of physical property may vary • Level of complexity may vary • • • • Basic binary sensors, basic analog sensors Complex analog sensors, complex digital sensors Integrated modules Bimetal, thermistor, TMP036, DS18B20, fire alarm Sensors Actuators And then some… Coding and sketches My First Circuit • Controlling a LED 9 Declaration of variables Initialization (only once) Hello World! (Blink) Main loop (ad infinitum) Arduino programming language • • • • C (or C++) variant "Sketches" instead of programs "Small" language Complex features are hidden from view • But are available if needed • Usual control structures • if, if-else, for, while, do-while, switch • Usual functions • Parameterization • return Arduino programming language • Usual operators • ==, !=, <, =<, &&, ||, !, ++, +=, *=, <<, etc. • Usual datatypes • boolean, char, byte, (unsigned) int, long, float, double, string, array, String (object) • Usual standard functions • min(), abs(), sqrt(), cos(), tan(), random(), etc. • Boring language... !? Simple... !? • Lots of syntactic sugar Arduino programming language • Digital I/O • pinMode(pin, INPUT/OUTPUT/INPUT_PULLUP) • digitalWrite(pin, HIGH/LOW) • digitalRead(pin) • LOW < 1.5 Volt, HIGH > 3 Volt • Analog I/O • analogRead(pin) • 0 .. 5 Volt, ranging 0 .. 1023 (10 bit resolution A/D converter) • analogWrite(pin, 0 .. 255) • Pulse Width Modulation (PWM), 500 Hz PWM Arduino programming language • Time • • • • millis() micros() delay() delayMicroseconds() • Structure • setup() • loop() • Our Hello World application has a problem! • More on that later… Circuits Connecting an RGB led • Three leds in one package… • …sharing a common lead • Common anode versus common cathode Connecting a button • Unconnected input pins are floating • A pull-down or pull-up resistor is needed • Pull-up resistors are generally preferred Connecting a light sensor • Light Dependent Resistor (LDR) • A microcontroller can't sense resistance directly • …but can sense voltage levels • Convert resistance to voltage • …using a voltage divider Motion and distance sensors • Connecting these is pretty straightforward • You may need to solder on some wires and configure Connecting a temperature sensor • Your temperature sensor is quite advanced • DS18B20 compatible one-wire device • One-wire protocol • Actually a communication bus • Needs a pull-up Connecting an LCD • Lots of wires! • Backlight with series resistor • Voltage divider for contrast • Easy coding! • Library