+ All Categories
Home > Documents > Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max)...

Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max)...

Date post: 08-Sep-2019
Category:
Upload: others
View: 12 times
Download: 2 times
Share this document with a friend
40
Curs Arduino ALEXANDRU-IOAN POP SEPTEMBRIE 2017 COLEGIUL NAȚIONAL “MIHAI EMINESCU” SATU MARE
Transcript
Page 1: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

Curs ArduinoALEXANDRU-IOAN POP

SEPTEMBRIE 2017

COLEGIUL NAȚIONAL “MIHAI EMINESCU” SATU MARE

Page 2: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

Despre mine

Anul 4 – Computer Science and Electronics

Bristol

Page 3: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

Informații suplimentare

alexandruioan.me/curs.php

Page 4: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

Arduino Nano

Page 5: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

Arduino Nano

Page 6: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200
Page 7: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200
Page 8: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

Ce e un microcontroller?

Atmega 386P Intel i5-6500

RAM 2KB (max) 64GB (max)

Frecventa 16MHz 3.2-3.6GHz

Putere consumată 0.36mW 30W

Preț $2 $200

Dimensiune 49 mm^2 1300 mm^2

Numar instrucțiuni 131 ~2000

Page 9: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

Instalare

Page 10: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

Configurare

Page 11: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

Structura unui program Arduino

Page 12: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

Exemplu 1: Blink

Page 13: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

Breadboard

Page 14: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

- +

Page 15: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200
Page 16: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

Exemplu 2: Buton

Page 17: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

Fritzing

• Scheme, diagrame pentru circuite

http://fritzing.org/download/?donation=0

• Fișierele, pe site

Page 18: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

Exemplu 2: Buton

Page 19: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

Exemplu 2: Buton

Page 20: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

Comunicarea cu calculator: portul serial

• Transmisiune serială, asincronă (fără semnal de ceas)

• Cele mai comune setări, 9600 8N1

• 9600 bps

• 8 biți de date

• Fără bit de paritate

• 1 bit de oprire

Page 21: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

Comunicarea cu calculator: portul serial

• UART = universal asynchronous receiver-transmitter

• Implementează protocoale de transmisiune serială

• RS-232 (protocol vechi, standard, între dispozitive)

Page 22: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

Comunicarea cu calculator: portul serial

Convertor serial-USB

Page 23: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

Comunicarea cu calculator: portul serial

Page 24: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

Lumea înconjurătoare e analogică

• Conversie prin ADC/DAC

ADCDAC

Page 25: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

Exemplu 3: citirea setării unui potențiometru (reostat)

Page 26: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

analogRead()

• 10 biti = 1024 nivele; 0 – 5V cu precizie de 4.9 mV

Page 27: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

Divizorul de tensiune

R1 R2 Vout

0 R2 Vin

R1 0 0

R R Vin/2

Page 28: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

analogWrite()

• Arduino nu are DAC încorporat

• Aproximație - PWM

Page 29: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

PWM – Pulse Width Modulation

• Proprietatea codificată = lățimea pulsului

• factor de umplere (duty cycle)

• Controlează:

• Intensitatea unui LED

• Viteza unui motor

• Pini PWM pe Arduino Nano: 3, 5, 6, 9, 10, și 11

Page 30: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

Exemplu 4: LED reglabil

Page 31: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

Exemplu 4: LED reglabil

Page 32: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

Servomotoare

• Unghi configurabil: 0° – 180°

Page 33: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

Cum se controlează un servomotor

Page 34: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

Exemplu 5: Servo

Page 35: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

Exemplu 5: Servo

Page 36: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

Exemplu 6: servo + potențiometru

Page 37: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

Exemplu 6: servo + potențiometru

Page 38: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

LED WS2812B

• LED programabil, adresabil (într-un șir, poate fi

controlat fiecare, individual)

• Red, Green, Blue (RGB)

• 3 x 8 biți / LED

• Protocol de comunicație simplu

Page 39: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

Instalarea bibliotecii

Page 40: Curs Arduino - alexandruioan.me · Ce e un microcontroller? Atmega 386P Intel i5-6500 RAM 2KB (max) 64GB (max) Frecventa 16MHz 3.2-3.6GHz Putere consumată 0.36mW 30W Preț $2 $200

Exemplu 7: demo NeoPixel


Recommended