programming in arduino n.
Skip this Video
Loading SlideShow in 5 Seconds..
Programming in Arduino PowerPoint Presentation
Download Presentation
Programming in Arduino

Loading in 2 Seconds...

play fullscreen
1 / 20

Programming in Arduino - PowerPoint PPT Presentation

  • Uploaded on

Programming in Arduino. Pre Pres. Notes. Casperelectronics. Photos from workshop?. Materials:Arduino Board. has the IDE programming software for free download. Arduino Sketch. Arduino files are called “sketches”.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'Programming in Arduino' - edythe

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
programming in arduino

Programming in Arduino

Pre Pres. Notes


Photos from workshop?

Materials:Arduino Board

arduino sketch
Arduino Sketch

Arduino files are called “sketches”.

Arduino sketches must be compiled in the IDE before being downloaded to the Arduino board.

program structure
Program Structure
  • Two required functions in an Arduino sketch, setup() and loop().
  • setup() The function is called when your program starts. Use it to initialize your variables, pin modes, start using libraries, etc. The setup function will only run once, after each powerup or reset of the Arduino board.
  • Loop() After creating a setup() function, which initializes and sets the initial values, the loop() function does precisely what its name suggests, and loops consecutively, allowing your program to change and respond. Use it to actively control the Arduino board.
what does void mean
What does “void” mean
  • The void keyword is used only in function declarations. It indicates that the function is expected to return no information to the function from which it was called.


  • Extend the capabilities of Arduino IDE
  • Offer simpiler ways of controlling hardware they are written for.
  • Advanced. will talk about later.
  • Let you store a value.
  • Must declare variables and tell computer what kind of value to expect.

Int- number between -32,768 to 32,767

Byte- 0 -255

char- type character

and more……

int variable
Int variable

int- an integer is a whole number (1,2,3,25)

  • are your primary datatype for number storage, and store a 2 byte value (take 2 bytes of memory). This yields a range of -32,768 to 32,767


int ledpin = 13; // sets the variable named ledpin to 13

char variable
Char variable

char- A data type that takes up 1 byte of memory that stores a character value.

Both of these are equivalent and refer to the letter A:

char myChar = 'A';

char myChar = 65; in ASCII

byte variable
Byte variable
  • Byte- an integer between 0 and 255 (byte uses less memory, only 1 byte)
  • Made up of 8 bits.

Example in binary:

00000001, 00000011


Binary Numbering (how computers count)

If computers only know 1 and 0 how do they form complex operations?

  • 128 64 32 16 8 4 2 1
  • 00000001 = 1
  • 00000010 = 2
  • 00000011= 3
  • 00000100 = 4

Programming- Functions

  • Segmenting code into functions allows a programmer to create modular pieces of code that perform a defined task and then return to the area of code from which the function was "called".
  • Existing Functions- commands Arduino automatically understands
  • Custom Functions -The typical case for creating a function is when one needs to perform the same action multiple times in a program.
example functions pinmode digitalwrite and delay
Example Functions:pinMode(), digitalWrite(), and delay()
  • The pinMode() function configures a pin as either an input or an output.

pinMode(ledPin, OUTPUT); // sets the digital pin as output

  • The digitalWrite() function outputs a value HIGH or LOW on a pin. For example, the line:

digitalWrite(ledPin, HIGH); //sets pin high

  • The delay() causes the Arduino to wait for the specified number of milliseconds before continuing on to the next line. There are 1000 milliseconds in a second, so the line:

delay(1000); // creates a delay of one second.

pseudocode blink an led
Pseudocode: Blink an Led


I want an led to blink, on for a second and off for a second forever.


Turn led on


Turn led off

Loop again

pseudocode translation
Pseudocode Translation

void loop() // run over and over again


digitalWrite(ledPin, HIGH); // sets the LED on

delay(1000); // waits for a second

digitalWrite(ledPin, LOW); // sets the LED off

delay(1000); // waits for a second


blink an led w o comments
Blink an Led(w/o comments)

int ledPin = 13;

void setup()


pinMode(ledPin, OUTPUT);


void loop() {

digitalWrite(ledPin, HIGH);


digitalWrite(ledPin, LOW);




Blink an Led

int ledPin = 13; // LED connected to digital pin 13

void setup() // run once, when the sketch starts


pinMode(ledPin, OUTPUT); // sets the digital pin as output


void loop() // run over and over again


digitalWrite(ledPin, HIGH); // sets the LED on

delay(1000); // waits for a second

digitalWrite(ledPin, LOW); // sets the LED off

delay(1000); // waits for a second



HW : Bring in a video or webpage link that is related to Physical Computing that you think is interesting and be prepared to talk about it in class.