第二周課程 arduino介紹
DESCRIPTION
Introduce the arduino in NCKU microcontroller course.TRANSCRIPT
f
Networked Embedded Applications and Technologies Lab
Department of Computer Science and Information Engineering National Cheng Kung University, TAIWAN
Free-Software Arduino
Kuan-Yu, Chen陳冠宇
Department of Computer Science and Information EngineeringNational Cheng Kung University, TAIWAN 2NEAT
Outline
What is Arduino? Source Kernel architecture Signal message.
What can you do by Arduino? Develop environment
Just do it LEDs UART PWM(Explain by Servo) Analysis product
Department of Computer Science and Information EngineeringNational Cheng Kung University, TAIWAN 3NEAT
Download Software.
www.arduino.cc
Department of Computer Science and Information EngineeringNational Cheng Kung University, TAIWAN 4NEAT
Download Software.
Department of Computer Science and Information EngineeringNational Cheng Kung University, TAIWAN 5NEAT
What is Arduino?
Department of Computer Science and Information EngineeringNational Cheng Kung University, TAIWAN 6NEAT
Source
From Italian Ivrea university.
David Mellis 、 David Cuartielles 、 Gianluca Martino 、 Massimo
Banzi 、 Tom Igoe
Department of Computer Science and Information EngineeringNational Cheng Kung University, TAIWAN 7NEAT
Kernel Architecture
IC Type
8 bits 8051 、 ATMEGA8
16 bits PIC 、 MSP430
32 bits ARM
• Only one schedule.
Department of Computer Science and Information EngineeringNational Cheng Kung University, TAIWAN 8NEAT
Kernel Architecture
Department of Computer Science and Information EngineeringNational Cheng Kung University, TAIWAN 9NEAT
Kernel Architecture
Microcontroller ATmega328
Operating Voltage 5V
Input Voltage (recommended) 7-12V
Digital I/O Pins 14(6 for PWM)
Analog Input Pins 6
DC Current per I/O Pin 40mA
DC Current for 3.3V Pin 50mA
Flash Memory 32KB(0.5 KB for bootloader )
Clock Speed 16Mhz
SRAM 2 KB
EEPROM 1KB
Department of Computer Science and Information EngineeringNational Cheng Kung University, TAIWAN 10NEAT
Kernel Architecture
Department of Computer Science and Information EngineeringNational Cheng Kung University, TAIWAN 11NEAT
Kernel Architecture
GPIO(General-purpose input/output) AD(Analog to Digital) Interrupt PWM(Pulse-width modulation) UART(Universal asynchronous reciver/transmitter) SPI(Serial peripheral interface) I2C(Inter-Integrated Circuit) … …
Department of Computer Science and Information EngineeringNational Cheng Kung University, TAIWAN 12NEAT
Signal message.
Sensor
Digital
Analog
Input/Output
Control
Display
Department of Computer Science and Information EngineeringNational Cheng Kung University, TAIWAN 13NEAT
What can you do by Arduino?
Department of Computer Science and Information EngineeringNational Cheng Kung University, TAIWAN 14NEAT
Develop environment
Base on C/C++.
Function. (By library)
Open-Source. (Include hardware and software)
Easy.
Department of Computer Science and Information EngineeringNational Cheng Kung University, TAIWAN 15NEAT
Check Board.
Check Serial Port.
Department of Computer Science and Information EngineeringNational Cheng Kung University, TAIWAN 16NEAT
Compile.
Download.
Department of Computer Science and Information EngineeringNational Cheng Kung University, TAIWAN 17NEAT
Just do it
Department of Computer Science and Information EngineeringNational Cheng Kung University, TAIWAN 18NEAT
include<> or ””
void setup{}
void loop{}
Department of Computer Science and Information EngineeringNational Cheng Kung University, TAIWAN 19NEAT
LEDs
pinMode(GPIO,Pin mode);
digitalWrite(Pin,state);
delay(time);
Department of Computer Science and Information EngineeringNational Cheng Kung University, TAIWAN 20NEAT
UART
Serial.begin(baud rate); Serial.available();
If receive someting. Serial.read();
Return value of receive. Serial.println(Value);
Department of Computer Science and Information EngineeringNational Cheng Kung University, TAIWAN 21NEAT
Department of Computer Science and Information EngineeringNational Cheng Kung University, TAIWAN 22NEAT
Department of Computer Science and Information EngineeringNational Cheng Kung University, TAIWAN 23NEAT
Lab
1. Try LEDs, UART and PWM(Servo).
2. Turn on the LED(pin13) if UART receive “H”.
3. Modify angle of motor by UART.
Department of Computer Science and Information EngineeringNational Cheng Kung University, TAIWAN 24NEAT
1. DC Motor2. Reducing gear3. Controller4. Sensor
Department of Computer Science and Information EngineeringNational Cheng Kung University, TAIWAN 25NEAT
Department of Computer Science and Information EngineeringNational Cheng Kung University, TAIWAN 26NEAT
控制方法原理: PWM控制1.Use Servo.h
2.Set initial position.
3.Control.
Department of Computer Science and Information EngineeringNational Cheng Kung University, TAIWAN 27NEAT
PWM
include<Servo.h>
Servo name;
name.attach(pin);
name.write(pos);
Department of Computer Science and Information EngineeringNational Cheng Kung University, TAIWAN 28NEAT
Refer
2014 Arduino, www.arduino.cc
1know.net, http://1know.net/knowledge/97636f101c46?v=list
Arduino IDE introduction, Wiki, Decr, 2011,
http://zh.wikipedia.org/wiki/Arduino
孫駿榮、吳明展、盧聰勇 , “Arduino 一試就上手 (第二版 ),,
,碁峯資訊出版 , Sep,2012.
賴文章、陳冠宇 , “Arduino入門級中文教學” , Jan,2012.