0% found this document useful (0 votes)
20 views

Arduino

Uploaded by

Dijana Jurić
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Arduino

Uploaded by

Dijana Jurić
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 87

ARDUINO UNO R3

http://arduino.cc/
Download
version 1.8.5.
Arduino
• Open source hardware i Software platforma
Dijelovi Arduino uno IDE
Tool Bar
Arduino web editor

• https://create.arduino.cc/
• Podržan s Chrome, Firefox, Safari...
• Treba kreirati free Arduino account
• Kada je plugin instaliran dobije se web editor:
Konfiguriranje
• Arduino spojiti s računalom
• Izabrati Select Board or Port
Primjeri
• Examples dobijete kategorije
Odličan za početnike

• DigitalReadSerial
Dodavanje tabova Arduino IDE
Rad s tabovima
• Kreirati tabove led.h i led
• U jednom su definirane konstante u drugom je kod
Manipulacija s dvije varijable

Ovdje je jednostavan primjer manipulacije s dvije varijable :


// Globalne varijable
int var1 = 10;
int var2 = 20;

void setup() {
// Samo se jednom izvrši kod boot_anja Arduino_a
var2 = 5; // var2 dobije vrijednost 5 once
}

void loop(){
// Kods e izvršava od gore prema dolje i kontinuirano ponavlja
if (var1 > var2){ // Ako je var1 većas od var2
var2++; // Inkrement var2 za 1
} else { // Ako var1 nije veća od var2
var2 = 0; // var2 postaje 0
}
}
Rad s breadboard (eksperimentalnom pločicom)
Spajanje LED diode
LED blinkanje:
// Deklariranje LED pin_a
int LED = 2;

void setup() {
// Deklariranje LED pina kao Output
pinMode(LED, OUTPUT);
}

void loop(){
// Uključivanje LED i wait 200 millisekundi
digitalWrite(LED, HIGH);
delay(200);
// Isključivanje LED i wait 200 millisekundi
digitalWrite(LED, LOW);
delay(200);
Fading the external LED
// Declare the LED pin with PWM
int LED = 3;

void setup() {
// Declare the pin for the LED as Output
pinMode(LED, OUTPUT)
}

void loop(){
// Here we will fade the LED from 0 to maximum, 255
for (int i = 0; i < 256; i++){
analogWrite(LED, i);
delay(5);
}
// Fade the LED from maximum to 0
for (int i = 255; i >= 0; i--){
analogWrite(LED, i);
delay(5);
}
}
PWM
RGB LED
Program
Declare the PWM LED pins void loop(){
int redLED = 9; // Change a few colors
int greenLED = 10; setColor(255, 0, 0); // Red Color
int blueLED = 11; delay(500);
void setup() { setColor(0, 255, 0); // Green Color
// Declare the pins for the LED as Output delay(500);
pinMode(redLED, OUTPUT); setColor(0, 0, 255); // Blue Color
pinMode(greenLED, OUTPUT); delay(500);
pinMode(blueLED, OUTPUT); setColor(255, 255, 0); // Yellow
} delay(500);
setColor(0, 255, 255); // Cyan
// A simple function to set the level for each color from 0 delay(500);
to 255 setColor(255, 0, 255); // Magenta
void setColor(int redValue, int greenValue, int blueValue) delay(500);
{
setColor(255, 255, 255); // White
analogWrite(redLED, 255 - redValue);
delay(500);
analogWrite(greenLED, 255 - greenValue);
}
analogWrite(blueLED, 255 - blueValue);
}
7-segment display
Program
// Declare the pins for the pinMode(pinUPL, OUTPUT); digitalWrite(pinDWL, LOW); digitalWrite(pinUPR, LOW);
Segment display pinMode(pinCT, OUTPUT); digitalWrite(pinUPL, LOW); digitalWrite(pinCT, LOW);
int pinUP = 2; // Upper segment } } digitalWrite(pinDWR, LOW);
int pinUPR = 3; // Up-right // If we want to write 1 digitalWrite(pinDW, LOW);
segment
void writeNumber(int value){ if (value == 1){ }
int pinDWR = 4; // Down-right
segment // First we erase the previous digitalWrite(pinUPR, LOW); }
value digitalWrite(pinDWR, LOW);
int pinDW = 5; // Down segment
digitalWrite(pinUP, HIGH); }
int pinDWL = 6; // Down-left
segment digitalWrite(pinUPR, HIGH); void loop(){
int pinUPL = 7; // Up-left segment digitalWrite(pinDWR, HIGH); // If we want to write 2 // A resetting count-down
int pinCT = 8; // Center segment digitalWrite(pinDW, HIGH); if (value == 2){ writeNumber(3);
digitalWrite(pinDWL, HIGH); digitalWrite(pinUP, LOW); delay(1000);
void setup() { digitalWrite(pinUPL, HIGH); digitalWrite(pinUPR, LOW); writeNumber(2);
// Declare the pins as Outputs digitalWrite(pinCT, HIGH); digitalWrite(pinCT, LOW); delay(1000);
pinMode(pinUP, OUTPUT); // If we want to write 0 digitalWrite(pinDWL, LOW); writeNumber(1);
pinMode(pinUPR, OUTPUT); if (value == 0){ digitalWrite(pinDW, LOW); delay(1000);
pinMode(pinDWR, OUTPUT); digitalWrite(pinUP, LOW); } writeNumber(0);
pinMode(pinDW, OUTPUT); digitalWrite(pinUPR, LOW); // If we want to write 3 delay(1000);
pinMode(pinDWL, OUTPUT); digitalWrite(pinDWR, LOW); if (value == 3){ }
digitalWrite(pinDW, LOW); digitalWrite(pinUP, LOW);
Button

Single Pole Single Throw (SPST)

Single Pole Double Throw (SPDT)


Button
Button
// Declare the pins for the Button and the LED // Read the value of the input. It can either be 1
int buttonPin = 2; or 0.
int LED = 13; int buttonValue = digitalRead(buttonPin);
if (buttonValue == HIGH) {
void setup() { // If button pushed, turn LED on
// Define pin #2 as input digitalWrite(LED,HIGH);
pinMode(buttonPin, INPUT); } else {
// Define pin #13 as output, for the LED // Otherwise, turn the LED off
pinMode(LED, OUTPUT); digitalWrite(LED, LOW);
} }
}
void loop() {
Button with no resistor
Button with no resistor
// Declare the pins for the Button and the LED // Read the value of the input. It can either be 1
int buttonPin = 12; or 0
int LED = 13; int buttonValue = digitalRead(buttonPin);
if (buttonValue == LOW){
void setup() { // If button pushed, turn LED on
// Define pin #12 as input and activate the digitalWrite(LED,HIGH);
internal pull-up resistor } else {
pinMode(buttonPin, INPUT_PULLUP); // Otherwise, turn the LED off
// Define pin #13 as output, for the LED digitalWrite(LED, LOW);
pinMode(LED, OUTPUT); }
} }

void loop(){
toggle switch
toggle switch
int buttonPin1 = 2; } digitalWrite(LED1, LOW);
int buttonPin2 = 3; digitalWrite(LED2, LOW);
void loop(){ } else if (buttonValue1 == LOW){
int LED1 = 5; // Read the value of the inputs. It can be // Button is toggled to the second pin
int LED2 = 6; either 0 or 1 digitalWrite(LED1, LOW);
// 0 if toggled in that direction and 1 digitalWrite(LED2, HIGH);
otherwise
void setup() { } else {
int buttonValue1 =
// Define the two LED pins as outputs digitalRead(buttonPin1); // Button is toggled to the third pin
pinMode(LED1, OUTPUT); int buttonValue2 = digitalWrite(LED1, HIGH);
pinMode(LED2, OUTPUT); digitalRead(buttonPin2); digitalWrite(LED2, LOW);
}
// Define the two buttons as inputs with if (buttonValue1 == HIGH && }
the internal pull-up resistor activated buttonValue2 == HIGH){
pinMode(buttonPin1, INPUT_PULLUP); // Switch toggled to the middle. Turn
pinMode(buttonPin2, INPUT_PULLUP); LEDs off
Button to serial
int buttonPin = 2; // Read the value of the input. It can either be
1 or 0.
void setup() { int buttonValue = digitalRead(buttonPin);
// Define pin #2 as input // Send the button value to the serial
connection
pinMode(buttonPin, INPUT_PULLUP);
Serial.println(buttonValue);

// Establish the Serial connection with a baud


rate of 9600 // Delays the execution to allow time for the
serial transmission
Serial.begin(9600);
delay(25);
}
}

void loop(){
Button debouncing
// Declare the pin for the button // Read the value of the input. It can either be 1 or 0
int buttonPin = 2; int buttonValue = digitalRead(buttonPin);
// Variable for keeping the previous button state if (buttonValue != previousButtonValue && millis() -
int previousButtonValue = HIGH; lastDebounce >= debounceTime){
// Reading is useable, print it
long lastDebounce = 0; // Last time the button was pressed Serial.println(buttonValue);
long debounceTime = 50; // Debounce delay
// Reset the debouncing timer
void setup() { lastDebounce = millis();
// Define pin #2 as input and activate the internal pull-up resistor // Change to the latest button state
pinMode(buttonPin, INPUT_PULLUP); previousButtonValue = buttonValue;
// Establish the Serial connection with a baud rate of 115200 }
Serial.begin(115200); // Allow some delay for the Serial data to be transmitted
} delay(10);
}
void loop(){
1,000 buttons to 1 pin
1,000 buttons to 1 pin
// Declare the Analog pin on the Arduino board Serial.println("S3");
int buttonPin = A0; } else if (buttonValue >= 300 && buttonValue < 400){
// A value between 300 - 400 represents the second button
void setup() { Serial.println("S2");
// Establish the Serial connection with a baud rate of 9600 } else if (buttonValue >= 400){
Serial.begin(9600); // A value greater than 400 represents the first button
} Serial.println("S1");
}
void loop(){
// Read the value of the input. It can vary from 0 - 1023
int buttonValue = analogRead(buttonPin); // Delays the execution to allow time for the Serial transmission
if (buttonValue < 200){ delay(25);
// A value under 200 represents no button pushed }
Serial.println("0");
} else if (buttonValue >= 200 && buttonValue < 300){
// A value between 200 - 300 represents the third button
Multipleksiranje
Button multiplexing - 4051
// Define the input pin on the Arduino and the 3 } // Then we read port IO3
selection pins connected to the 4051 digitalWrite(A, HIGH);
int buttonPin = 2; void loop(){ digitalWrite(B, HIGH);
int A = 10; // We first read port IO0 digitalWrite(C, LOW);
int B = 9; digitalWrite(A, LOW); int buttonIO3 = digitalRead(buttonPin);
int C = 8; digitalWrite(B, LOW); // Then we print to Serial the values
digitalWrite(C, LOW); // We print them in-line separated by a space
void setup() { int buttonIO0 = digitalRead(buttonPin); Serial.print(buttonIO0);
// Define pin #2 as input with the pull up // Then we read port IO1 Serial.print(" ");
resistor on
digitalWrite(A, HIGH); Serial.print(buttonIO1);
pinMode(buttonPin, INPUT_PULLUP);
digitalWrite(B, LOW); Serial.print(" ");
// Define the output pins going to the control
lines of the Multiplexer digitalWrite(C, LOW); Serial.print(buttonIO2);
pinMode(A, OUTPUT); int buttonIO1 = digitalRead(buttonPin); Serial.print(" ");
pinMode(B, OUTPUT); // Then we read port IO2 Serial.println(buttonIO3);
pinMode(C, OUTPUT); digitalWrite(A, LOW); // Delays the execution to allow time for the
serial
// Establish the Serial connection with a baud digitalWrite(B, HIGH);
rate of 9600 digitalWrite(C, LOW); delay(25);
Serial.begin(9600); int buttonIO2 = digitalRead(buttonPin); }
Senzori
 Jednostavni senzor – potenciometar
 Temperaturni senzor
 Detekcija pokreta – PIR senzor
 Mjerenje udaljenosti – infracrveni i ultrazvučni
 Redukcia šuma
 Akcelerometar
 Lokalizacija – GPS
Potenciometar
10-bit resolution
 Napon između: 0 and 5 V na 5V Arduinu imati će vrijednosti između
0 and 1023.
 Napon od 2.5 V će biti jednak 512, što je pola opsega
Potenciometar
int LED = 13; // Deklariranje LED void loop(){
int sensorPin = A2; // Deklariranje analog porta // Čitanje vrijednosti senzora
na koji je spojen senzor int val = analogRead(sensorPin);
// Print te vrijednosti na Serial
void setup(){ Serial.println(val);
// Start Serial konekcije // Blinkanje LED s kašnjenjem četvrtine
Serial.begin(9600); vrijednosti senzora
// Postavljanje LED pina kao OUTPUT digitalWrite(LED, HIGH);
pinMode(LED, OUTPUT); delay(val/4);
} digitalWrite(LED, LOW);
delay(val/4);
}
Senzor temperature – LM35
Senzor temperature – LM35
// Declare the LEDs in an array // On the LM35 each degree Celsius digitalWrite( LED[1], HIGH);
int LED [5] = {2, 3, 4, 5, 6}; equals 10 mV digitalWrite( LED[2], HIGH);
int sensorPin = A0; // 20C is represented by 200 mV which } else if (val > 53 && val < 57){ // 26 - 28
means 0.2 V / 5 V * 1023 = 41 C
// Declare the used sensor pin
// Each degree is represented by an digitalWrite( LED[0], HIGH);
analogue value change of approximately 2
void setup(){ digitalWrite( LED[1], HIGH);
// Set all LEDs off
// Start the Serial connection digitalWrite( LED[2], HIGH);
for (int i = 0; i < 5; i++){
Serial.begin(9600); digitalWrite( LED[3], HIGH);
digitalWrite(LED[i], LOW);
// Set all LEDs as OUTPUTS } else if (val > 57){ // Over 28 C
}
for (int i = 0; i < 5; i++){ digitalWrite( LED[0], HIGH);
pinMode(LED[i], OUTPUT); digitalWrite( LED[1], HIGH);
if (val > 40 && val < 45){ // 20 - 22 C
} digitalWrite( LED[2], HIGH);
digitalWrite( LED[0], HIGH);
} digitalWrite( LED[3], HIGH);
} else if (val > 45 && val < 49){ // 22 - 24
C digitalWrite( LED[4], HIGH);
void loop(){ digitalWrite( LED[0], HIGH); }
// Read the value of the sensor digitalWrite( LED[1], HIGH); delay(100);
int val = analogRead(sensorPin); } else if (val > 49 && val < 53){ // 24 - 26 // Small delay for the Serial to send
Serial.println(val); // Print it to the Serial C }
digitalWrite( LED[0], HIGH);
Detekcija kretanja – PIR senzor (pasivni IR)
PIR senzor
int LED = 13; // Declare the built-in //LED // Approximately 1-2 seconds
int sensorPin = 2; // Declare the used delay(3000); // We are waiting 3
//sensor pin }

void setup(){ void loop(){


// Set the LED pin as OUTPUT // Read the sensor, if it goes low, we
//the internal pull-up //blind the LED for 1 second
//resistorpinMode(LED, OUTPUT);
if (digitalRead(sensorPin) == LOW){
// Set the sensor pin as digital input //and
activate digitalWrite(LED, HIGH);
pinMode(sensorPin, INPUT_PULLUP); delay(1000);
// Wait for the sensor to take a digitalWrite(LED, LOW);
//snapshot of the room }
}
Mjerenje udaljenosti – infracrveni i ultrazvučni
Mjerenje udaljenosti
int sensorPin = A0; // Declare the sensor
used sensor pin int val = analogRead(A0);
int LED = 11; // Declare the // Print the value over Serial
connected LED
Serial.println(val);
// Write the value to the LED using
void setup(){ PWM
Serial.begin(9600); // Start the analogWrite(LED, val/4);
Serial connection
// Wait a little for the data to print
}
delay(100);
}
void loop(){
// Read the analog value of the
IR senzor – redukcija šuma
int sensorPin = A0; // Declare the used sensor pin // Variable to store the readings // Return the middle value
int raw[samples]; return raw[samples/2];
// Function that reads a sensor with specified // Read the samples each as a value in the vector }
number of samples for (int i = 0; i < samples; i++){
// Returns the mean filtered value raw[i] = analogRead(pin); void setup(){
int readMean(int pin, int samples){ } // Start the Serial connection
// Variable to store the sum of readings Serial.begin(9600);
int sum = 0; // Sort the values }
// Read the samples and add them all // Lazy bubble sort
for (int i = 0; i < samples; i++){ int temp = 0; // temp value void loop(){
sum = sum + analogRead(pin); for (int i = 0; i < samples; i++){ // Print the normal value and then a space
} for (int j = i; j < samples - 1; j++){ Serial.print(analogRead(sensorPin));
// Divide the sum by the number of samples // Check if values out of order Serial.print(" ");
sum = sum/samples; if (raw[j] > raw[j + 1]){ // Print the mean filtered value and then a space
// Return the sum // If so, swap them Serial.print(readMean(sensorPin, 15));
return sum; temp = raw[j]; Serial.print(" ");
} raw[j] = raw[j + 1]; // Print the median filtered value
raw[j + 1] = temp; Serial.println(readMedian(sensorPin, 15));
// Function that reads a sensor with specified } // Short delay for the Serial
number of samples
} delay(100);
// Returns the median filtered value
} }
int readMedian (int pin, int samples){
Akcelerometar – ADXL335
Akcelerometar – ADXL335
// Deklariranje LED pin Serial.print(" ");
int LED = 13; Serial.print(yVal);
Serial.print(" ");
// Deklariranje X,Y,Z analognih pinova Serial.println(zVal);
int xPin = A0; // Check for movement
int yPin = A1; // Values at rest:
int zPin = A2; // X ~ 330
// Y ~ 330
void setup(){ // Z ~ 400
Serial.begin(9600); // If movement, blink LED
pinMode(LED, OUTPUT); if (xVal < 310 || xVal > 350 || yVal < 310 || yVal > 350 || zVal
} < 380 || zVal > 420){
digitalWrite(LED, HIGH);
void loop(){ delay(300);
// Read 3 vrijednosti digitalWrite(LED, LOW);
int xVal = analogRead(xPin); }
int yVal = analogRead(yPin); // Mali delay za Serial
int zVal = analogRead(zPin); delay(50);
// Print 3 vrijednosti na Serial }
Serial.print(xVal);
Lokalizacija – GPS receiver (Copernicus)
GPS receiver
// Include Software Serial library softSerial.begin(9600); // Soft Serial
#includanje <SoftwareSerial.h> }

// Define a Software Serial object and


the used pins void loop(){
// Check for received characters
// Connect GPS TX to Soft Serial RX from the GPS
and GPS RX to Soft Serial TX
if (softSerial.available()){
SoftwareSerial softSerial(8, 9); // RX,
TX // Ispiši što je primljeno
Serial.write(softSerial.read());
void setup(){ }
Serial.begin(9600); // Normal Serial }
Arduino kontinuirano ispisuje:
• Ako se pokrene kod, sa spojenim GPS_om, dobit će se puno podataka
na serial monitoru. GPS će ispisati longitude, latitude, broj nađenih
satelita i jačinu signala. Može biti prikazano više detalja ako su
raspoloživi ovisno o GPS modulu.
• Upotrebom Copernicus modula unutar zgrade, Arduino kontinuirano
ispisuje:
• $GPGGA,,5316.82829,N,08650.76721,W,7,03,,,,,,,*4E
• Ovo znači 53.1682829 ekliptička širina (latitude), 8.65207672
ekliptička dužina (longitude), što odgovara sjevernom Bremenu,
Njemačka. Još pokazuje da su na raspolaganju tri satelita, a kvaliteta
signala je oko 7.
Kako radi triangulacija
• Objašnjenje rada GPS triangulacije, http
://electronics.howstuffworks.com/gadgets/travel/gps.htm
• Više detalja oko Arduino string manipulaciji,
http://arduino.cc/en/Reference/StrsingObject
Kontrola motora

 kontrola malih motora


 kontrola motora s tranzistorima
 kontrola brzine s PWM
 okretanje motora u oba smjera
 Servo motor
 Step motor
 Bipolarni step motor
 Brushless motor
Upravljanje malim motorima
Mali motor
// Deklariranje pina za motor digitalWrite(motorPin, HIGH);
int motorPin = 2; // Wait 1000 ms
delay(1000);
// Isključi motor
void setup() { digitalWrite(motorPin, LOW);
// Definiranje pina 2 kao output // Wait 1000 ms
pinMode(motorPin, OUTPUT); delay(1000);
}
}
void loop(){
// Uključi motor
Upravljanje motorima preko tranzistora
DC motor, otpornik između 220 ohma i 10K ohma, standardni
NPN tranzistor (BC547, 2N3904, N2222A, TIP120), standardna
dioda (1N4148, 1N4001, 1N4007)
Kod - isti

// Deklaracija pina za motor // Uključi motor


int motorPin = 2; digitalWrite(motorPin, HIGH);
// Wait 1000 ms
delay(1000);
void setup() { // Isključi motor
// Definiranje pina 2 kao output digitalWrite(motorPin, LOW);
pinMode(motorPin, OUTPUT); // Wait 1000 ms
delay(1000);
} }

void loop(){
Pull-down otpornik s NPN tranzistorom
S PNP tranzistorom
N – KANALNI MOSFET (FQP30N06, IRF510, IRF520)

Prvi do 30 A i 60 V , druga dva do 5.6 A i 10 A, respektivno, pri


100 V
Kontrola brzine s PWM
DC motor, otpornik između 220 ohma i 4,700 ohma, standardni NPN
tranzistor (BC547, 2N3904, N2222A, TIP120) ili MOSFET (IRF510,
IRF520), standardna dioda (1N4148, 1N4001, 1N4007)
PWM kod
// Deklariranje pina za motor delay(1000);
int motorPin = 9; // Uključi motor na 1/2 snage
analogWrite(motorPin, 127);
void setup() { // Wait 1000 ms
// PWM pinovi ne zahtjevaju delay(1000);
pinMode() funkciju // Isključi motor
} analogWrite(motorPin, 0);
// Wait 1000 ms
void loop(){ delay(1000);
// Uključi motor na maximum }
analogWrite(motorPin, 255);
// Wait 1000 ms //PWM pinovi su 3, 5, 6, 9, 10, i 11
Vrijednosti PWM

Skoro svi Arduini imaju 8-bit PWM signal na frekvenciji od 490 Hz.
Izuzetak su novije varijante npr. Uno koji na pinovima 5 i 6, daju 980 Hz.
8-bit PWM znači da izlazna vrijednost može biti od 0 do 255 a sredina
je na 127.
Vrtnja u oba smjera
Polarizacija motora određuje smjer vrtnje.
Za to je potreban H – Bridge ili neki od shieldova.
Kod - vrtnja u oba smjera različitim brzinama
// Deklariranje upotrebljenih pinova digitalWrite(directionPin, HIGH); delay(1000);
int directionPin = 12; // Set speed // Motor full speed forwards
int pwmPin = 3; analogWrite(pwmPin, val); setMotor(255);
} delay(1000);
// If the value is from -255 to 0 the // Motor stop
void setup() { motor will spin backwards setMotor(0);
// Set directionPin kao OUTPUT if (val < 0){ delay(1000);
pinMode(directionPin, OUTPUT); // Set smjera // Motor half speed backwards
// PWM pinovi ne zahtjevaju digitalWrite(directionPin, LOW); setMotor(-127);
pinMode() funkciju // Set speed, -val because the value is delay(1000);
} negative and positive is requried
// Motor full speed backwards
analogWrite(pwmPin, -val);
setMotor(-255);
// Custom function which controls the }
delay(1000);
speed and direction using one variable. }
// Motor stop
void setMotor(int val){
setMotor(0);
// If val is from 0 to 255 the motor will void loop(){
spin forwards delay(1000);
// Turn motor on half speed forwards
if (val >= 0){ }
setMotor(127);
// Set the direction
Arduino UNO R3 – najpopularniji kod maker
(community) zajednice
Arduino UNO R3
• Može se koristiti AC-to-DC adapter ili baterija. Izvor napajanja se može
spojiti s 2,1 mm utikačem s (+) u sredini a vanjski dio je (-).
• Arduino Uno radi na 5 V ali može imati maksimalni ulazni napon 20V
• Ipak se ne preporučuje korištenje većeg napona od 12V
• Koristi linearni regulator (za kontrolu napona spojenog na pločicu.
• USB Port: može se upotrijebiti za napajanje ili programiranje pločice.
• RESET button: Ovaj button, kad se pritisne, resetirati će pločicu.
• ICSP za USB: (In-Circuit Serial Programming) pinovi se upotrebljavaju
flash_anje firmware na USB interface chip.
• Digitalni i PWM konektori: pinovi, označeni s 0 do 13, mogu se koristit
kao digitalni ulazni ili izlazni. Pinovi označeni s tildom (~) mogu se još
koristiti kao Pulse-Width Modulation (PWM) izlaz.
Arduino UNO R3
• Analogni ulazni konektori: Pinovi označeni s A0 do A5 mogu biti
upotrijebljeni kao analogni ulazi. Ovi pinovi mogu se koristiti za čitanje
izlaza iz analognog senzora.
• Power i External Reset (napajanje i vanjski reset): Ovi pinovi daju
masu i napajanje za vanjske sklopove i senzore od Arduina. Arduino se
također može napajati preko tih pinova. Postoji i reset pin koji se
može upotrijebiti za reset Arduina.
• ATmega328: Mikrokontroler za Arduino Uno ploču

Digitalni/PWM/Analog in/Power/Reset konektori se zajedno zovu pin


headeri. Pinovi u ovim headerima omogučuju Arduinu komunikaciju s
vanjskim sensorima i ostalim sklopovi.
Napajanje Arduina

Arduino se može napajati na tri načina:

1. Preko VIN/GND pinova


2. DC Supply Input port
3. USB port.
DC ulazni port
• AC/DC adapter ili baterija
• Konektor ima ženski 2.1 mm u sredini (+) utikač
• Dok Arduino radi s 5V, maksinalni napon adaptera je 20V (preporuka
ne više od 12 V)
Napajanje Arduina preko VIN/GND pinova
Ne preporučuje se
(mogu se koristiti baterije 6xAA u seriju, skuplje i kraće traju)
Napajanje preko USB konektora
 Direktno preko USB porta računala
 USB punjivih baterija
Arduino shieldovi
• Modularni sklopovi koji se spajaju direktno na pinove headera ploče
Arduino, daju mu novu funkcionalnost, na njih se spajaju novi ....
• Vrste: Internet, prepoznavanje i sinteza govora, upravljanje DC
motorima ...
Arduino pinovi
• Ukupno 31 pin, većina se konfigurira za različite funkcije
Analogni ulazni pinovi

• Šest ADC (Analog-To-Digital) pretvarača, šest ulaza


• Ulaz ima vrijednosti od 0 do 1023 referentne vrijednosti Arduina (kod
Arduino Uno je to 5V)
• Ovih šest pinova mogu se konfigurirati kao digitalni
PWM pinovi
• Izlazni, PWM (Pulse With Modulation) je tehnika prikazivanja
analognog rezultata digitalnim izlazom
• Digitalni izlaz oscilira između HIGH i LOW
Digitalni pinovi
• Za spajanje vanjskih senzora
• Po defaultu su ulazni
• Mogu biti ulazni ili izlazni
• Mogu se čitati ili pisati u njih
• Imaju dvije vrijednosti: - HIGH (1) što je 5V
- LOW(0), koji je 0V
Pinovi napajanja

• VIN: za napajanje Arduina vanjskim naponom


• GND: pin mase (uzemljenja)
• 5V: izlaz je 5V i koristi se za napajanje večine senzora
• 3.3V: izlaz je 3.3V i koristiti se za napajanje senzora koji rade na 3.3V
• Reset: reset Arduino ploče iz vanjskog izvora
• Ioref: (referentni napon ploče, za Arduino Uno je 5V
Serial pinovi

• Koriste se za serijsku komunikaciju


• RX (digital pin 0) – receive (prijem)
• RX (digital pin 1) – transmit (predaja)
• Ovi pinovi spojeni su direktno na USB-to-TTL serijski čip
• Ne spajati ove pinove direktno na RS-232 serijski port (oštetiti ćete
svoju Aruino ploču)
SPI pinovi (Serial Pheripheral Interface)

• SPI protokol se koristi za sinkroni serijski prijenos između


mikrokontrolera i vanjskih jedinica
• Uvijek je jedan Master a ostali su Slave
• Pinovi: - MISO (Master in Slave out: podaci sa Slave idu u Master)
- MOSI (Master out Slave in: Master šalje podatke na Slave)
- SCK (Serial clock: sinkronizira prijenos , stvara ga Master)
- SS (Slave Select: aktivira koji je Slave omogućen za transfer s
masterom
Drugačije Arduino ploče
https:/​/​www.​arduino.​cc/​en/​Main/​Products – razne vrste
• Ostale popularne vrste:
• Arduino Micro
• Arduino Mega 2560
• Lilypad
• Arduino Nano
Arduino Micro
• ATmega32U4 mikrokontroler
• 20 digitalnih I/O pinova: 7 za PWM, 12 mogu biti analogni ulazi
• Za manje projekte
Arduino Mega 2560
• Za kompleksne projekte (npr. robot)
• 53 digitanla I/O pina: od toga može biti 16 analognih ulaza i 15 PWM
izlaza, ima 4 serijska UART-a za serijsku vezu.
Lilypad
• Za prijenosne projekte
• Baza je ATmega168V ili ATmega328V
• 16 digitalnih I/O pinova: od toga 6 analognih ulaza i 6 PWM izlaza
Arduino Nano
• 14 digitalnih I/O pinova: 8 analognih ulazna i 6 PWM izlazna pina
Generičke pločice

• Oficijelni Arduino logo ima znak ∞ i (+) , (-) u njemu


• Jeftinije su od originala
Generičke Arduino Uno pločice
Generička Arduino Mega 2560 pločica
Fritzing dijagrami

• Slikovni prikaz izgleda izgleda spajanja komponenti kruga


• http:/​/​fritzing.​org/​learning – besplatan, open source
• Koristi slike za stvaranje kruga

You might also like