This wiki has been archived and made read-only.
For up-to-date information about TkkrLab and it's projects please visit our main website at tkkrlab.nl.

HowTo simple Arduino project

From

Revision as of 20:12, 5 June 2018 by FFAA5E (Talk | contribs) (Initial version)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Simple Arduino sensor & acturator projects

The Arduino is an open hardware mircocontroller platform. A microcontroller can be used has the hart of a device that responds to an event by a certain action. Sensors are used to sense that a certain event or condition has occured. Acturators (including displays) are used to perform the action.

What?

A project starts with the formulation of a short description of what one want to achieve. Questions that need to be answered are

  • What do I want to sense?
  • What do I want to act or display?
  • With state or not? (Time words: after, when, ..)

An example of a stateless device is a light switch to switch a light on/off. An example of a device with a state is a lamp that is triggered by movement: the light goes on when some movement is detected and stays of until for 10 second no movement has been detected.

It is a good idea to draw a State Diagram, starting from the initial state and thinking about all the events/triggers that could happen. For each of this a line is drawn to a state. And then continue on with a state that has not been investigated yet. Whenever a state is reached that is equivalent to an earlier state, one can draw the line to that state.

Sensors

Sensors can be devided into three types: on-off, analog, and serial

On-off

Examples of on-off sensors are:

Analog

The Arduino can measure a voltage between 0V and 5V with 1024 levels.

Examples:

Simple, but low resolution and/or accuracy.

Serial (digital)

Examples:

Actuators

Three types: on-off, analog, and serial

On-off

  • LED
  • Relay shield

Analog

Not really analog: Pulse-width modulation (PWM)
Arduino: 255 levels, 500Hz.


Serial (digital)

Displays

Others

Programing

Initialization and loop.

The loop:

  • Read sensors
  • Make decision (on state)
  • Activate acturators
  • Sleep

Program structure

Everything in a single file and libraries.

  • Include statements of libraries
  • Pin definitions
  • (Functions)
  • Initialization: void setup()
  • Loop: void loop()

Links