我爱编程

[Mooc]IoT Course 2 The Arduino P

2017-04-04  本文已影响0人  Vinchent

Week 1 Arduino Environment

Lesson 1

Lecture 1.1 Arduino Platform

A development board
Arduino Environment
A software environment
Special-purpose "Shields"
The Arduino Decelopment Board

Power/reset: Reset button; USB connector; Power connector

Lecture 1.2 Arduino Board

  1. Input/Output Pins: Digital I/O; Power/reset pins; Analog inputs
  2. Microcontrollers
    • ATmega328 is the processor programmed by the user
    • ATmega16U2 handles USB communication
  3. Two types of code executing on a simple mocrocontroller:
    • Application code
      • Executes the system's main functionality
      • We write this code
    • Firmware
      • Low-level code: supports the main function
      • USB interface, power modes, reset, etc.
    • The distinction is a matter of perspective
    • Arduino firmware is pre-programmed

Lecture 1.3 Direct Programming

Bootloader
In-Circuit Serial Programming (ICSP)

Lesson 2

Lecture 2.1 Arduino Schematics

Arduino UNO Schematic

Lecture 2.2 Arduino IDE

IoTM2W1L2.2.png

Arduino Integrated Development Environment(IDE)

Lecture 2.3 Compiling Code

Compiling Code
Serial Monitor

Lesson 3

Lecture 3.1 Arduino Shields and Libraries

Arduino Shields
Some Arduino Shields

Ethernet Shield; Color LCD shield; Synhesizer Shield(generate music and connect to a speaker)

Ethernet Shield Library Example

Lecture 3.2 Arduino Basic Setup


Week 2 C Programming

C_Lesson1
C_Lesson2
C_Lesson3
C_Lesson4
C_Lesson5

Lesson 1

Lecture 1.1 Setting Up Your Environment

Getting Started
Running a Program

Lecture 1.2 Hello World

Breaking Down Hello.c
    #include <stdio.h>
    {}
    printf(...);
    main() {
        printf("hello, ");
        printf("world");
        printf("\n");
    }

"hello, world\n"

Lecture 1.3 Variables

Variables
    int x;
    float y;
Types and Type Qualifiers
Type Size Notes
char 1 byte Fixed size
int Typically word size 16 bit minimum
[float Floating point 64 bits, typical
double Double-precision 64, 128 typical
Variable Names

Lesson 2

Lecture 2.1 Basic C Operators

Constants
    #define ANSWER 42
Arithmetic/Relational Operators
Logical Operators

Lecture 2.2 Conditionals

Conditional Statements

if

if (expression)
    statement1
else
    statement2
if (expression)
    statement1
else if (expr2)
    statement2
else 
    stat3

Switch

switch (expr) {
    case const_expr1: stat1
    case const_expr2: stat2
    default: stat3
}

Lecture 2.3 Loops

While and For Loops
for (expr1; expr2; expr3)
    statement
expr1;
while(expr2) {
    statement
    expr3;
}
do {
    statement
    expr3;
} while (expr2);
Break and Continue

Lesson 3

Lecture 3.1 Functions

Functions
Function Arguments

Data can be passed to functions as arguments

Function Return Value

Lecture 3.2 Global Variables

Global Variables
Globals Are Dangerous

Week 3

BuildProcess
Setup
Loop
PinMode
DigitalWrite
DigitalRead
AnalogRead

Lesson 1 Arduino Programs

Lecture 1.1 Arduino Toolchain

Verify and Upload
IoTM2W3L1.1.png
Combine and Transform

Lecture 1.2 Cross-Compilation

Compile and Link
Hex File Creation and Programming

Lecture 1.3 Arduino Sketches

Arduino Programs
Object-Oriented Programming

Lesson 2

Lecture 2.1 Classes

Classes and Members
class X {
public:
    int m;
    int mf(int v) { int old = m; m=v ; return old; }
};

X var;
var.m = 7;
int é = var.mf(9);
Classes in Libraries
Ethernet.begin(mac);
Serial.begin(speed);
client.print("Hello");
Serial.print("Hello");

Lecture 2.2 Sketch Structure

Setup() Function
Loop() Function

Lecture 2.3 Pins

Pins
Output Pins

Output pins are controlled by the Arduino

Input Pins
Digital vs. Analog

Lesson 3

Lecture 3.1 Input and Output

Input/Output(I/O)
Digital Input
int digitalRead(pin)
Digital Output
void digitalWrite(pin, value)
Analog Input
int analogRead(pin)

Lecture 3.2 Blink Examples

Delay
void delay(msec)
Blink Example

Week 4

Serial

Lesson 1

Lecture 1.1 Debugging

Debug and Trace

Controllability and observability are required

Controllability
Observability
I/O Access Is Insufficient

Observation of I/O is not enough to debug

Properties of a Debugging Environment
  1. Run control of the target
    • Start and stop the program execution
    • Observe data at stop points
  2. Real-time monitoring of target execution
    • Non-intrusive in terms of performance
  3. Timing and functional accuracy
    • Debugged system should act like the real system

Lecture 1.2 Debug Environment

Remote Debugger
Remote Debug Tradeoffs

Advantages:

  1. Good run control using breakpoints to stop execution
  2. Debug monitor can alter memory and registers
  3. Perfect functional accuracy

Disadvantages:

  1. Debug interrupts alter timing so real-time monitoring is not possible
  2. Need a spare communication channel
  3. Need program in RAM(not flash) to add breakpoints
Embedded Debug Interfaces
Debug and Trace Features

Lecture 1.3 Debug via Serial

Serial Protocols
UART
UART

Lesson 2

Lecture 2.1 UART Protocol

Simple UART Structure
IoTM2W4L2.1.png
UART Timing Diagram
IoTM2W4L2.1_2.png
Bit Duration

Lecture 2.2 UART Synchronization

UART Synchronization
IoTM2W4L2.2.png
Start Bit, Synchronization
IoTM2W4L2.2_2.png

Lecture 2.3 UART Parity and Stop

Parity Bit
Stop bit
Data throughput vs. Baud

Lesson 3

Lecture 3.1 Serial on Arduino

Arduino Serial Communication
Sending Text Over Serial

Lecture 3.2 Reading from Serial

Reading Data Over Serial
Serial.read()
    char buff[10];
    Serial.readBytes(buff, 10);
上一篇下一篇

猜你喜欢

热点阅读