Sunday, January 29, 2017

Lab 7 - Introduction to Microcontrollers

What is a Microcontroller?

A microcontroller is pretty much a computer on a chip.  It looks like a small piece of black plastic with a bunch of metal legs protruding from the sides and goes on a circuit board.  Microcontrollers are a lot than meets the eye as it is low-cost and has many function integrated into it to perform specific operations.  The microcontroller is an integrated circuit (IC) that contains memory, processing units, and input/output circuitry on a small chip that interfaces with a much larger circuit board that may have sensors, switches, and motors.  Every microcontroller that is purchased comes as a "blank", which means you need to plug it into your computer and program it with a specific control program.  When the microcontroller is programed with a specific purpose it can then be built into a product to make it more intelligent and easier to use.  A super, big plus of a microcontroller is that it can replace a number of separate parts and components, or complete an electronic circuit.  Everyday products that use microcontrollers are household appliances, alarm systems, medical equipment, vehicle subsystems, and electronic instrumentation.

Advantages:
  • Increase reliability through a smaller part count
  • Reduce stock levels, as one microcontroller replaces several parts
  • Simplified product assembly and smaller end products
  • Greater product flexibility and adaptability since features are programmed into the microcontroller and not built into the electronic hardware
  • rapid production changes or development by changing the program and not the electronic hardware
Demonstrate Knight Rider LED Flashing Band

Materials:
  • Arduino Board
  • Breadboard
  • Sufficient wire
  • 4 LEDs
  • 4 resistors between 200-500 Ohms (Red, red , brown is 220ᘯ is ideal)
Summary:

To show how simple and easy it is to get started with programming the Arduino we needed to go to the link Arduino.cc to download the Programming Environment for the Arduino (PEA).  It took about 5 minutes to download everything needed for this lab.  The PEA is also easy to navigate with example lessons.  First we need to make sure the settings are correct by clicking "Tools" so that the PEA can communicate and transfer programs to the Arduino via USB cable.  We start off with a program called Blink and run the program to the Arduino to blink its orange light built into the board.  Then we are tasked to change the blinking intervals from 1 second to half of a second.

We first go over three functions that are easy to understand: pinMode(Pin #, Input/Output), digitalWrite(Pin #, LOW/HIGH), and delay(time in milliseconds).  The pinMode() function initializes the digital I/O pin on the Arduino board and defines it as an output signal for switches or input signal for sensors.  The digitalWrite() function tells the pin being used to either be HIGH (5V or 3.3V) or LOW (0V).  HIGH and LOW can be thought of as On and Off.  The delay() function causes the Arduino to halt execution for the specified time between its parenthesis bar in milliseconds.


K.I.T.T. LED Flash (Program as typed into PEA):

void setup()

{
pinMode(10,OUTPUT);  //Initialize Digital Pin 10 as an output
pinMode(9,OUTPUT);  //Initialize Digital Pin 9 as an output
pinMode(8,OUTPUT);  //Initialize Digital Pin 8 as an output
pinMode(7,OUTPUT);  //Initialize Digital Pin 7 as an output
}

void loop()

{
digitalWrite (10,HIGH);  //Set the LED On
delay(500);                      //Wait for 500ms
digitalWrite(10,LOW);   //Set the LED Off
delay(500);                     //Wait for 500ms

digitalWrite (9,HIGH);
delay(500);
digitalWrite(9,LOW);
delay(500);

digitalWrite (8,HIGH);
delay(500);
digitalWrite(8,LOW);
delay(500);

digitalWrite (7,HIGH);
delay(500);
digitalWrite(7,LOW);
delay(500);

digitalWrite (8,HIGH);
delay(500);
digitalWrite(8,LOW);
delay(500);

digitalWrite (9,HIGH);
delay(500);
digitalWrite(9,LOW);
delay(500);
}     


No comments:

Post a Comment