Beruflich Dokumente
Kultur Dokumente
2016
DAY 1:
ARDUINO
MICROCONTROLLER
Polytechnic University of the Philippines, Santa Rosa | Aljhon Abila, 4 th Year BSECE
HISTORY:
Hernando Barragan created the development
platform Wiring at the Interaction Design
Institute Ivrea in Italy.
Massimo Banzi and Casey Reas known for
their work on Processing
GOAL: To create low cost, simple tools for nonengineers to create digital projects. The Wiring
platform consisted of a hardware PCB with an
ATmega128 microcontroller, an IDE based on
Processing and library functions to easily
program the microcontroller.
ARDUINO Microcontroller Programming | ECE Summer Workshop 2016
HISTORY:
2005 Banzi, Mellis, and Cuartielles added
support for the cheaper ATmega8
microcontroller to Wiring.
Then, started running a separate project called
ARDUINO.
Arduinos Initial core Team:
Massimo Banzi
David Cuartielles
Tom Igoe
Gianluca Martino
David Mellis
ARDUINO Microcontroller Programming | ECE Summer Workshop 2016
HISTORY:
The name ARDUINO comes from a bar in Ivrea,
where some of the founders of the project
used to meet. (Arduin of Ivrea)
Hardware:
A microcontroller board based on
the ATmega328.
It has 14 digital input/output
pins, and 6 analog inputs.
Consists of a 16 MHz ceramic
resonator, a USB connection, a
power jack, an ICSP header, and a
reset button.
The board features serial
communications interfaces,
including USB on some models,
for loading
from
ARDUINO programs
Microcontroller Programming
| ECE Summer Workshop 2016
ECE SUMMER
WORKSHOP
2016
ACTIVITY
LED|LCD|7Segment
Polytechnic University of the Philippines, Santa Rosa | Aljhon Abila, 4 th Year BSECE
ECE SUMMER
WORKSHOP
2016
LED
Light Emitting
Diode
Polytechnic University of the Philippines, Santa Rosa | Aljhon Abila, 4 th Year BSECE
Blink: digitalWrite()
function
Turns on an LED on for one
second, then off for one second,
repeatedly.
Most Arduinos have an on-board
LED you can control. On the Uno
and Leonardo, it is attached to
digital pin 13.
Diode)
Fade: analogWrite()
function
This example shows how to
fade an LED on pin 9 using the
analogWrite() function.
Sample CODE:
int led = 9;
int brightness = 0;
int fadeAmount = 5;
void setup() {
pinMode(led, OUTPUT);
}
void loop() {
analogWrite(led, brightness);
// set the brightness of pin 9:
// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if (brightness == 0 || brightness == 255) {
fadeAmount = -fadeAmount ;
}
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
ARDUINO Microcontroller Programming | ECE Summer Workshop 2016
Sample CODE:
// constants won't change. They're used here to set pin numbers:
const int buttonPin = 2;
// the number of the pushbutton pin
const int ledPin = 13;
// the number of the LED pin
// variables will change:
int buttonState = 0;
// variable for reading the pushbutton status
void setup() {
pinMode(ledPin, OUTPUT); // initialize the LED pin as an output:
pinMode(buttonPin, INPUT);
// initialize the pushbutton pin as an input:
}
void loop() {
buttonState = digitalRead(buttonPin); // read the state of the pushbutton value:
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
}
else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}
ARDUINO Microcontroller Programming | ECE Summer Workshop 2016
ECE SUMMER
WORKSHOP
2016
LCD
Liquid Crystal
Display
Polytechnic University of the Philippines, Santa Rosa | Aljhon Abila, 4 th Year BSECE
It is aflat-screendisplayinwhichanarrayofliquid
-crystalelementscanbeselectivelyactivatedtogenera
teanimage,an
electricfieldappliedtoeachelementalteringitsoptical
properties.
A flat-panel display that is
madeofanarrayofcellscontainingliquid
crystalsthataligntoblockortransmitlight
inresponsetoan electriccurrent.
How it Works?
Nematic Phase Liquid Crystals.
- is the most commonly used in LCDs
How it Works?
1.Polarizing filter vertical
2.Glass substrate with Indium
Tin Oxide(ITO) electrodes.
3. Twisted nematic liquid
crystal.
4.Another substrate
5.Polarizing filter horizontal
6.Reflective Surface
ARDUINO Microcontroller Programming | ECE Summer Workshop 2016
Simulation (Proteus):
The circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* LCD R/W pin to ground
* LCD VSS pin to ground
* LCD VCC pin to 5V
Potentiometer:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
ARDUINO Microcontroller Programming | ECE Summer Workshop 2016
#include <LiquidCrystal.h>
// include the library code:
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
lcd.begin(16, 2); // set up the LCD's number of columns and
rows:
lcd.print("hello, world!"); // Print a message to the LCD.
}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
lcd.print(millis() / 1000); // print the number of seconds since
reset:
}
ARDUINO Microcontroller Programming | ECE Summer Workshop 2016
ECE SUMMER
WORKSHOP
2016
7-Segment LED
Display
Polytechnic University of the Philippines, Santa Rosa | Aljhon Abila, 4 th Year BSECE
7-Segment LED
Display
A common type of display device using
LEDs is the seven-segment display.
By forward-biasing selected
combinations of segments, any decimal
digit and a decimal point can be
formed.
Two type of led circuit arrangements
are the common anode and common
cathode
ARDUINO Microcontroller Programming | ECE Summer Workshop 2016
PINS
Sample CODE:
First, initialize all variables.
Declare the pins to be used.
int
int
int
int
int
int
int
l0=2;
l1=3;
l2=4;
l3=5;
l4=6;
l5=7;
l6=8;
void setup()
{
pinMode(l0,OUTPUT);
pinMode(l1,OUTPUT);
pinMode(l2,OUTPUT);
pinMode(l3,OUTPUT);
pinMode(l4,OUTPUT);
pinMode(l5,OUTPUT);
pinMode(l6,OUTPUT);
}
In the void loop, set the necessary pins to high to make a digit-0. Give it a second, then reset
the pins to make a digit-1. Do this for the rest of the digits (from 0-9).
void zero()
{
//make a digit-0.
digitalWrite(l0,HIGH)
;
digitalWrite(l1,HIGH)
;
digitalWrite(l2,HIGH)
;
digitalWrite(l3,HIGH)
;
digitalWrite(l4,HIGH)
void nine()
{
//make a digit-9.
digitalWrite(l0,HIGH)
;
digitalWrite(l1,HIGH)
;
digitalWrite(l2,HIGH)
;
digitalWrite(l3,HIGH)
;
digitalWrite(l4,LOW);
END
ARDUINO Microcontroller Programming | ECE Summer Workshop 2016