Download Basic Arduino

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
1
1. Computer Literacy
Name:
Topic: Basic Arduino
A. What is Arduino?
Arduino is a microcontroller, also referred to as MCU (Microcontroller Unit).
Arduino can be used to develop an interactive environment with various sensors, using switches
(switches) or input switches (sensors), various Lights, Motors, and other physical outputs. Arduino
programs can run independently or in combination with other Software running (e.g. Flash,
Processing, MaxMSP).
Digital Input (DI) means that the sensor detects the external voltage signal and changes and then converts it
into the corresponding digital signal input.
Digital Output (DO) means that the sensor receives a digital signal and generates a corresponding signal
output, thereby triggering other external devices to issue warnings or other related applications.
The Pin, 5V, 3.3V, and GND pins are Arduino power pins.
2
B. Why do we use Arduino?
Advantages
Reason
Low Price
Arduino’s motherboards are relatively inexpensive compared to other MCU
platforms. You can buy the finished product. The price will not be higher than
HKD $200. (compared to Raspberry Pi and MintDuino)
Cross-Platform
Arduino software runs on Windows, Macintosh OSX and Linux operating
systems. Most teaching MCU systems is limited to Windows.
Simple, clear
programming
The Arduino programming environment is easy for beginners to get started with,
but also provides enough for advanced users ‘sufficient flexibility. It is convenient
for teachers to process the programming environment on the basis, allowing
students to easy to get familiar with the look and feel of the Arduino.
Open source and
extensible
software/
hardware
The language can be expanded through C++ libraries, and people wanting to
understand the technical details can make the leap from Arduino to the AVR C
programming language on which it's based. Even relatively inexperienced users
can build the breadboard version of the module to understand how it works and
save money.
3
C. Introduction of electronic components
Breadboard
Terminal Strips
A breadboard is a rectangular plastic board with a bunch of tiny holes in it. These holes let you easily
insert electronic components to prototype (meaning to build and test an early version of) an electronic
circuit, like this one with a battery, switch, resistor, and an LED.) It has terminal strips in each row. The
horizontal holes are linked together, but not across the middle divider.
Button
A button is a physical switch that controls a device's function. It helps to complete or disconnect a.
circuit by clicking it
Resistors
4
Resistors are often represented by R in circuits, and their characteristics are electronic components that
prevent the passage of current. The larger the resistance value, the more resistance to electricity. The
greater the resistance, the unit of resistance value is expressed as (Ω). In use, it will be represented by kΩ
(102Ω) or MΩ (106Ω) resistance value.)
LED (light-emitting diode)
A light-emitting diode (LED) is a semiconductor light source that emits light when current flows through
it. Remember that positive side is the longer side and negative side is the shorter side.
Variable Resistors
Variable resistor is an electronic component with three terminals, and the resistance value at both ends of
its periphery is a fixed value. They are often represented by VR. The middle point is used to change the
length of the carbon film or metal wire by means of rotation or sliding, to change the resistance value of
the outer two points and the middle contact. Its resistance value (the resistance value at both ends of the
periphery) can be adjusted arbitrarily within a certain range. The purpose of the variable resistor is: It is
used for the user to control the functions of volume, sound quality, voltage, power, etc. in the electronic
device.
Connecting Wires
Connecting wires allows an electrical current to travel from one point on a circuit to another because.
electricity needs a medium through which it can move. Most of the connecting wires are made up of
copper or aluminum.
5
D. Status of Connection
An open circuit implies that the two terminals are points are externally disconnected, which is equivalent
to a resistance R = ∞ . This means that zero current can flow between the two terminals.
A closed circuit implies that current can flow between the two terminals. Every component can function
well because current can flow between the two terminals
A short circuit implies that the two terminals are externally connected with resistance R = 0, the same as
an ideal wire. This means there is zero voltage difference for any current value. (Note that real wires
have non-zero resistance!)
Be careful**** It will cause electric fire due to excessive current flowing.
E. Relationship between Voltage, Current and Resistance
Voltage - act as pushing character
Current – energy running through the circuit
Resistance – Block/Hamper the Current flow
6
F. Tinkercad: Circuit (Demo)
Case 1: LED Blinking
Please draw the electrical diagram of the following circuit. (Assume the Arduino board is the power supply)
7
Create account with google
Click “join now”  Click student account  Sign in with Google
After that, click ‘circuit’  ‘Build new circuits’
Try to connect the circuit as the picture shown.
Hint:
1x Arduino board
1x Breadboard
1x LED
1x Resistor
8
Function
Setup()
Loop()
DigitalWrite()
PinMode (Value,
INPUT/OUTPUT)
Delay()
Description
Initializing variables, pin modes. The setup function will only run once
Loops consecutively, allowing your program to change and respond.
Write a HIGH or a LOW value to a digital pin.
Configures the specified pin to behave either as an input or an output
Pauses the program for time (in milliseconds) specified as parameter. (1
second = 1000 milliseconds)
Meaning of the code
1. Set Pin 13 as Output
2. Current is allowed to flow in Pin 13. (HIGH)
3. Wait 1 second.
4. Current is not allowed to flow in Pin 13. (LOW)
5. Wait 1 second.
2. Current is allowed to flow in Pin 13. (HIGH)
3. Wait 1 second.
4. Current is not allowed to flow in Pin 13. (LOW)
5. Wait 1 second.
2. Current is allowed to flow in Pin 13. (HIGH)
3. Wait 1 second.
4. Current is not allowed to flow in Pin 13. (LOW)
5. Wait 1 second.
…
HW: How to change into two LEDs blinking?
Hint: LED(a) on , LED (b) off
LED(a) off, LED (b) on