What Is a Microcontroller? — Programming an Arduino Board

Updated on August 9, 2018
eugbug profile image

Eugene is a qualified control/instrumentation engineer Bsc (Eng) and has worked as a developer of electronics & software for SCADA systems.

Typical Arduino development board
Typical Arduino development board | Source
DIL (Dual In Line) integrated circuits (ICs) or "chips"
DIL (Dual In Line) integrated circuits (ICs) or "chips" | Source

What is a Microcontroller?

You probably have lots of these in your home although you don't know it! A microcontroller is a type of integrated circuit (IC) or "chip" which is often used in devices in your home which incorporate electronic circuitry. You have probably heard of microprocessors, e.g. Intel Pentium, and these are used as the CPU (Central Processing Unit), effectively the "brain", in a computer. Microprocessors are integrated circuits which process the instructions in a computer program, perform calculations and send data to and from memory and disk. A microcontroller is a specific type of microprocessor. It differs from a normal microprocessor in the following ways:

  • It has built in "I/O" (input/output) capabilities. So it can read and write digital and analog values/states, and connect directly to the "real world". A microcontroller, unlike a microprocessor can connect directly to switches, buttons, LCD displays, LEDS, relays and serial ports
  • Microcontrollers are generally used for low to medium complexity, specific tasks in equipment. This contrasts with the powerful, number crunching microprocessors used in PCs which handle a variety of software applications.
  • Microcontrollers are often used in portable devices which run on batteries, e.g. digital cameras. So they are often low powered with a small current consumption (unlike the heat sinked, fan cooled microprocessor in a desktop computer)
  • Compared to the microprocessor in a PC, the RAM within a microcontroller can typically range from 64k down to as little as 1k
  • The program in a microcontroller is usually stored in EPROM or EEPROM. This is a type of non volatile (program doesn't disappear when the device is turned off) memory which can be continuously wiped and rewritten.


Microcontroller Uses

Lots of devices make use of microcontrollers. Some examples:

  • Burglar alarms incorporate a microcontroller chip which is connected to the keypad, display and sensor/contact inputs. Microcontrollers are generally self contained chips with the ALU (Arithmetic Logic Unit), memory and I/O all contained within one integrated circuit
  • Older automatic washing machines used a cam switch for sequencing the operations during a wash cycle. This was quite a complex switch and was mounted on the end of the shaft of the knob you used to select a wash program. Newer machines use a microcontroller to sequence operations. Other appliances such as microwave ovens and dishwashers may incorporate a microcontroller
  • TVs use microcontrollers to handle the selection of channels and reading the state of buttons on the TV
  • Microcontrollers are used for engine control and display of information on the dashboard (fascia) of vehicles
  • Digital cameras use microcontrollers to handle input from buttons, control of image capture and display.

Microcontroller Examples

Some commonly used microcontrollers:

  • Zilog Z8
  • Intel 8051
  • Texax Instruments TIMSP430
  • Atmel AVR

What is an Arduino?

Arduino is an open source hardware/software programming platform based around Atmel microcontrollers. Open source means that circuit schematics and source code of software used in designs is freely available and can be modified by enthusiasts. Arduino development boards with their analog and digital, inputs and outputs, are ideal for artists, designers and electronic hobbyists who wish to put together a system without having to know a huge amount about digital design. Input and output signals are made available on the Arduino board using rows of female connectors into which individual leads or single in line (SIL) connectors can be plugged.

An Arduino development board will have at least:

  • 9 digital pins which can be either input/output channels. Some of these can be setup as PWM (Pulse Width Modulation) outputs. A PWM signal is a square wave whose pulse width can be varied. PWM is used for speed and position control of motors and servos in robotics and remote control applications
  • 4 analog input channels.
  • At least one serial port which may also be used for download of code to the Arduino

Some boards also have a range of analog output channels.

There is a high degree of flexibility as regards the function of pins, some of which can be configured as either analog or digital. Digital pins can be configured as either input or output.

Arduino boards sense the environment around them as they receive input from sensors connected to these analog and digital inputs. They can also control actuators such as motors, alarm sounders and electric valves, or switch on LEDS, lamps or other visual indication devices. The output drive capability of outputs is limited, so usually transistors, FETS, or relays must be used between the Arduino output pin and driven device. An output is capable however, of driving LEDs directly.

The connectors on board are arranged in a standard manner so that shields can be connected. Shields are modules with a dedicated function (e,g, infra-red output, bluetooth, GSM, WIFI, Ethernet, motor on/off control using relas, stepper motor control). Depending on the shield type, it may be possible to stack several shields on top of each other and address them individually over an I2C, serial bus.

Since the Arduino code and hardware is open source, third party developers have produced clones of the official Arduino boards.

Arduino boards have from 32 to 512k of flash memory which can be used for program storage



Arduino Leonardo with Headers
Arduino Leonardo with Headers

This is the first Leonardo board I started using. It has a modest amount of I/O including 20 digital I/O ports, 7 PWM channels, 12 12 bit analog input channels and 5 analog output channels. Headers are soldered onto the board, but you may be able to find a version without them if you need more space.

 

What Can an Arduino Board Be Used For?

An Arduino board can be used for doing lots of cool stuff. You can easily add LCD displays, a keypad or seven segment display modules and build a simple system quickly. Lots of information and libraries are available on the Arduino.cc website. You can design your own add on electronics or use shields to build a modular system. Arduinos because of their versatility can be used for simple, mundane tasks or complex applications. An example of a simple application would be the ability to turn on a device when the temperature in a room falls below a certain level. It wouldn't be too difficult to extend this application, and add a GSM module which could send out a text message when this occurs. Arduino boards can be used to implement a complex home automation system which could be controlled over a smart phone. They are also used by enthusiasts as the processing and control device in robots, and kits are available for building a simple wheeled robot.

Micontroller Projects — Programming an Arduino Board

Arduino boards are programmed in C and high level functions are provided as standard for reading and writing to analog and digital pins and serial ports. Source code is known as a "sketch". Standard libraries are also available for tasks such as output to an LCD panel or communication with a GSM module. Lots of other libraries and code have been contributed by enthusiasts and are available on the Arduino website.

A basic code editor/compiler is available on the Arduino website which can be used for developing programs. However the editor is basically just like Wordpad and doesn't provide any color coded highlighting or have sophisticated debug features. Atmel Studio, a cut-down, customized version of Visual Studio is an alternative which provides these features.

Programs are downloaded onto an Arduino board using either a serial port or USB connection. A bootloader then loads the program into memory on reset so that an external programmer isn't required.



Leonardo - a specific model Arduino board. Digital pins can be configured as either input or output. Several digital pins can double up as analog inputs in addition to the standard analog inputs
Leonardo - a specific model Arduino board. Digital pins can be configured as either input or output. Several digital pins can double up as analog inputs in addition to the standard analog inputs | Source

Simple Arduino Sketch

// A simple sketch written in C which can be run on an
// Arduino board

 

// Simple program to read a character from the serial port, echo
// it back to the remote terminal and flash an LED

void setup()

{
Serial.begin(9600) // Open the port at 9600 baud
pinMode(13,OUTPUT) // Set pin 13 as an output
}

void loop() 
{
char character;

if(Serial.available()) // if there is data in the receive buffer.....
{
character = Serial.read(); // read the character
Serial.write(character); // echo the character to the serial port

// Flash an LED
digitalWrite(13,HIGH); // turn on the LED connected to pin 13
delay(50) // delay 50 mS
digitalWrite(13,LOW); // turn off the LED connected to pin 13

}
Comduino Terminal, an application for reading and writing Arduino i/o pins - available on my blog (check my profile for the link)
Comduino Terminal, an application for reading and writing Arduino i/o pins - available on my blog (check my profile for the link) | Source

Questions & Answers

© 2014 Eugene Brennan

Comments

    0 of 8192 characters used
    Post Comment

    • PDXBuys profile image

      PDXBuys 

      3 years ago from Oregon

      If I am lucky Santa will bring me one of these for Christmas.

    working

    This website uses cookies

    As a user in the EEA, your approval is needed on a few things. To provide a better website experience, turbofuture.com uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

    For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at: https://turbofuture.com/privacy-policy#gdpr

    Show Details
    Necessary
    HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
    LoginThis is necessary to sign in to the HubPages Service.
    Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
    AkismetThis is used to detect comment spam. (Privacy Policy)
    HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
    HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
    Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
    CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
    Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the googleapis.com or gstatic.com domains, for performance and efficiency reasons. (Privacy Policy)
    Features
    Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
    Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
    Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
    Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
    Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
    VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
    PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
    Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
    MavenThis supports the Maven widget and search functionality. (Privacy Policy)
    Marketing
    Google AdSenseThis is an ad network. (Privacy Policy)
    Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
    Index ExchangeThis is an ad network. (Privacy Policy)
    SovrnThis is an ad network. (Privacy Policy)
    Facebook AdsThis is an ad network. (Privacy Policy)
    Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
    AppNexusThis is an ad network. (Privacy Policy)
    OpenxThis is an ad network. (Privacy Policy)
    Rubicon ProjectThis is an ad network. (Privacy Policy)
    TripleLiftThis is an ad network. (Privacy Policy)
    Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
    Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
    Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
    Statistics
    Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
    ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
    Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)