You are on page 1of 25

CENTRE FOR SKILL AND

ENTREPRENEURSHIP
DEVELOPMENT
ON
CONTROLLER USE IN IOT
IIOT - 1
BASIC ARDUINO PROGRAMS

TECHNOLOGYPROVIDER
TECHNOLOGY PARTNER HOSTING PARTNER
CSED ARDUINO BOARD

• “Strong Friend” Created in Ivrea, Italy


• in 2005 by Massimo Banzi & David Cuartielles
• Open Source Hardware
• Processor
• Coding is accessible & transferrable  (C++, Processing, java)

2
2
CSED GETTING STARTED – H/W & S/W

1. SW Installation: Arduino (v.1.0+)

2. Fritzing /Tinkercad

3. Drivers

4. Materials
1. Arduino Board
2. Analog I/O, Digital I/O, Serial, & Fritzing/Tinkercad
3. Arduino Data sheet
3
3
CSED ARDUINO BOARD DESCRIPTION
USB
PWR IN (to Computer)

RESET

SCL\
SDA
POWE (I2C Bus)

R
5V / 3.3V / Digital I\O
GND PWM(3, 5, 6, 9, 10,
Analog 11)
INPUT
S 4
4
CSED GO AHEAD AND PLUG YOUR BOARD IN!

5
5
CSED ARDUINO SHIELDS

Micro SD MP3 Trigger LCD

6
6
CSED INPUT/ OUTPUT

Image from Theory and Practice of Tangible User Interfaces at UC Berkley


7
7
CSED BASIC COMPONENTS

Name Image Type Function Notes


Push Button Digital Input Switch - Closes or opens Polarized, needs resistor
circuit
Trim potentiometer Analog Input Variable resistor Also called a Trimpot.

Photoresistor Analog Input Light Dependent Resistor Resistance varies with


(LDR) light.
Relay Digital Output Switch driven by a small Used to control larger
signal voltages

Temp Sensor Analog Input Temp Dependent


Resistor
Flex Sensor Analog Input Variable resistor

Soft Trimpot Analog Input Variable resistor Careful of shorts

RGB LED Dig & Analog Output 16,777,216 different Ooh... So pretty.
colors

8
8
CSED BASIC COMPONENTS

9
9
CSED BASIC COMPONENTS

10
10
CSED BASIC COMPONENTS

11
11
CSED BASIC COMPONENTS

12
12
CSED CONCEPTS: INPUT VS. OUTPUT

Output is any signal exiting the


board.
Inputs is a signal / information
going into the board.

Almost all systems that use physical computing will have some form
of output
13
13
CSED CONCEPTS: INPUT VS. OUTPUT

Inputs is a signal / information Output is any signal exiting the


going into the board. board.

Examples: Buttons Switches, Light Examples: LEDs, DC motor, servo


Sensors, Flex Sensors, Humidity motor, a piezo buzzer, relay, an RGB
Sensors, Temperature Sensors… LED

14
14
CSED CONCEPTS: ANALOG VS. DIGITAL

1. Microcontrollers are digital devices – ON or OFF. Also called –


discrete.

2. Analog signals are anything that can be a full range of values.

5V 5V

0V 0V

15
CSED OPEN UP ARDUINO

•For PC Users 
1.Let the installer copy and move For Mac Users 
the files to the appropriate
locations, or 1. Move the Arduino
executable to the dock for
2.Create a folder under C:\ ease of access.
Program Files (x86) called
Arduino. Move the entire Arduino 2. Resist the temptation to
program folder here. run these from your
desktop.

16
CSED ARDUINO INTEGRATED DEVELOPMENT ENVIRONMENT (IDE)

Two required functions / methods /


routines:

void setup()
{
// runs once
}

void loop()
{
// repeats
Error & status messages }
17
CSED SETTINGS: TOOLS  SERIAL PORT

1. Your computer
communicates to the
Arduino microcontroller via
a serial port  through a
USB-Serial adapter.

2. Check to make sure that the


drivers are properly
installed.
Error & status messages
18
CSED SETTINGS: TOOLS  BOARD

1. Next, double-check that the proper board is selected under the


ToolsBoard menu.
Error & status messages
19
CSED PROGRAMMING CONCEPT

digitalWrite()

analogWrite()

digitalRead()

if() statements / Boolean

analogRead()

Serial communication
Error & status messages
20
CSED LET’S GET TO CODING – BLINK LED PROGRAM

Turn Turn Rinse &


Wait Wait
LED ON LED OFF Repeat

21
CSED COMMENTS, COMMENTS, COMMENTS

1. Comments are for you – the programmer and your friends…or anyone else
human that might read your code.

// this is for single line comments


// it’s good to put a description at the top and before anything ‘tricky’
/* this is for multi-line comments
Like this…
And this….
*/
22
22
CSED ARDUINO IDE

23
23
CSED THREE COMMANDS TO KNOW…

 pinMode(pin, INPUT/OUTPUT);

 ex: pinMode(13, OUTPUT);

 digitalWrite(pin, HIGH/LOW);

 ex: digitalWrite(13, HIGH);

 delay(time_ms);

 ex: delay(1000); // delay of 1 sec.


// NOTE: -> commands are CASE-sensitive

24
24
CSED
THANK YOU

25

You might also like