arduino: fundamentals and coding - engineering.tiu.edu.iq

19
Arduino: Fundamentals and Coding Mechatronics Department TIUI 01.0 Dr Ezideen A Hasso

Upload: others

Post on 28-May-2022

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Arduino: Fundamentals and Coding - engineering.tiu.edu.iq

Arduino: Fundamentals and Coding

Mechatronics Department TIUI

01.0

Dr Ezideen A Hasso

Page 2: Arduino: Fundamentals and Coding - engineering.tiu.edu.iq

Different types of Arduino’s

Page 3: Arduino: Fundamentals and Coding - engineering.tiu.edu.iq

Synopsis Arduino is a single board microcontroller based on a single

Integrated Circuit chip.

• There are variety of them, but this course will concentrate

on the Arduino Uno.

• The Arduino’s are open-source software open-source

hardware.

• They are widely used for education and hobbyists due to

low cost and availability.

Page 4: Arduino: Fundamentals and Coding - engineering.tiu.edu.iq
Page 5: Arduino: Fundamentals and Coding - engineering.tiu.edu.iq

RESETRESET2AREFioref

A0A1A2A3A4/SDAAS/SCL

N/C

D13 D12 D11 D10 D9 D8D7D6 D5 D4D3 D2D1 D0

GND

3V

3

5V

VIN

SCKMISOPWM/MOSIPWM/SSPWM

PWMPWM

PWM

TXRX

Arduino Uno

Schematic Pin

Diagram

Page 6: Arduino: Fundamentals and Coding - engineering.tiu.edu.iq
Page 7: Arduino: Fundamentals and Coding - engineering.tiu.edu.iq
Page 8: Arduino: Fundamentals and Coding - engineering.tiu.edu.iq

Static Charge

Electronic components are sensitive to static chargesand needs to be handled carefully otherwise could be

damaged. Discharging of tactile surfaces that are going

to be in physical contact with these components is a

must for the safety and prevention of damage. For

these reasons we find that electronic components are

usually supplied in static envelops (pouches).

Page 9: Arduino: Fundamentals and Coding - engineering.tiu.edu.iq

Installing Arduino

The Arduino boards need a development system where all the work is: performed; sketches (program or codes) are created and edited; compiled; and finally uploaded to the Arduino boards to be executed to conduct the intended tasks. To install Arduino software simply go to google and type the following:

Page 10: Arduino: Fundamentals and Coding - engineering.tiu.edu.iq

<Arduino downloads>

The response will be something like this:

Page 11: Arduino: Fundamentals and Coding - engineering.tiu.edu.iq

Windows 10

Click on the link:

Page 12: Arduino: Fundamentals and Coding - engineering.tiu.edu.iq

Arduino IDE:

IDE, can be considered as the operating theatre:

•Write

•Edit

•Compile

•Upload to Arduino board

Page 13: Arduino: Fundamentals and Coding - engineering.tiu.edu.iq

IDE front page

Page 14: Arduino: Fundamentals and Coding - engineering.tiu.edu.iq

Adamant to Write Your First Program Today

Do the Following Steps:

• <File>

• <Examples>

• <Basics>

• <BareMinimum>

Page 15: Arduino: Fundamentals and Coding - engineering.tiu.edu.iq

Choosing Board Type and Port

Page 16: Arduino: Fundamentals and Coding - engineering.tiu.edu.iq

Exercise 1

void setup() {

// put your setup code here, to run once:

pinMode(13, OUTPUT);

digitalWrite(13, HIGH);

}

void loop() {

// put your main code here, to

}

void setup() {

// put your setup code here, to run once:

pinMode(13,OUTPUT);

digitalWrite(13,HIGH);

delay(1000);

digitalWrite(13,LOW);

}

void loop() {

// put your main code here, to run repeatedly:

}

Change to “LOW”

Exercise 2

Add Delay

Page 17: Arduino: Fundamentals and Coding - engineering.tiu.edu.iq

Serial Port/*

Serial Port Usage

*/

void setup() {

// put your setup code here, to run once:

Serial.begin(9600); // define the Bps

Serial.print("The Mechatronics Engineering");

Serial.println("Would like to:\n welcome you all");

}

void loop() {

// put your main code here, to run repeatedly:

}

Control Charecter “\n”

Page 18: Arduino: Fundamentals and Coding - engineering.tiu.edu.iq

Serial.println("The Mechatronics Engineering");

Serial.print("The Mechatronics Engineering");

Copy and paste the Serial instruction to the void loop

and see the outcome

Change to “print”

Page 19: Arduino: Fundamentals and Coding - engineering.tiu.edu.iq

The End