EasyManuals Logo

Texas Instruments MSP430 Student Guide

Texas Instruments MSP430
398 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #379 background imageLoading...
Page #379 background image
Lab 8
Gettings Started with the MSP430 - Using Energia (Arduino) 8 - 21
2. Examine the code.
Looking at the Blink sketch, we see the code we quickly examined during our chapter
discussion. This code looks very much like standard C code. (In Lab8d we examine some of
the specific differences between this sketch and C code.)
At this point, due to their similarity to standard C language code, we will assume that you
recognize most of the elements of this code. By that, we mean you should recognize and
understand the following items:
#define – to declare symbols
Functions – what a function is, including: void, () and {}
Comments – declared here using // characters
What we do want to comment on is the names of the two functions defined here:
setup(): happens one time when program starts to run
loop(): repeats over and over again
This is the basic structure of an Energia/Arduino sketch. Every sketch should have – at the
very least – these two functions. Of course, if you don’t need to setup anything, for example,
you can leave it empty.
/*
Blink
Turns on an LED on for one second, then off for one second,
repeatedly. This example code is in the public domain.
*/
void setup () {
// initialize the digital pin as an output.
// Pin 14 has an LED connected on most Arduino boards:
pinMode (RED_LED, OUTPUT);
}
void loop () {
digitalWrite (RED_LED, HIGH); // turn on LED
delay (1000); // wait one second (1000ms)
digitalWrite (RED_LED, LOW); // turn off LED
delay (1000); // wait one second
}

Table of Contents

Other manuals for Texas Instruments MSP430

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Texas Instruments MSP430 and is the answer not in the manual?

Texas Instruments MSP430 Specifications

General IconGeneral
BrandTexas Instruments
ModelMSP430
CategoryMicrocontrollers
LanguageEnglish

Related product manuals