www.sainsmart.com Arduino Introduction Overview What is Arduino? Arduino is a tool for making computers that can sense and control more of the physical world than your desktop computer. It's an open-source physical computing platform based on a simple microcontroller board, and a development environment for writing software for the board. Arduino can be used to develop interactive objects, taking inputs from a variety of switches or sensors, and controlling a variety of lights, motors, and other physical outputs. Arduino projects can be stand-alone, or they can be communicated with software running on your computer (e.g. Flash, Processing, MaxMSP.) The boards can be assembled by hand or purchased preassembled; the open-source IDE can be downloaded for free. The Arduino programming language is an implementation of Wiring, a similar physical computing platform, which is based on the Processing multimedia programming environment. Feature Schematic design of the open source development interface free download, and also according to the needs of their own changes Download the program is simple and convenient. Simply with the sensor, a wide range of electronic components connection (such as: LED light, buzzer, keypad, photoresistor, etc.), make all sorts of interesting things. Using the high-speed micro-processing controller (ATMEGA328). The development of language and development environment is very simple, easy to understand, very suitable for beginners to learn. Performance Digital I/O 0~13. Analog I/O 0~5.( R3 is 0~7 ) Suppor Input voltage: when connected to the USB without external power supply or external 5 v output and external power input. Atmel Atmega328 micro-processing controller. Because of its many supporters, the company has developed 32- Arduino size: width of 70 mm X high 54 mm. Special Port 1. VIN. The input voltage to the Arduino board when it's using an external power source (as opposed to 5 volts from the USB connection or other regulated power source). You can Copyright © 2013 SainSmart All Rights Reserved www.sainsmart.com supply voltage through this pin, or, if supplying voltage via the power jack, access it through this pin. 2. AREF. Reference voltage for the analog inputs. Used with analogReference(). SainSmart UNO R3 What’s UNO R3? The Arduino Uno is a microcontroller board based on the ATmega328. It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz ceramic resonator, a USB connection, a power jack, an ICSP header, and a reset button. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started. Performance Revision 3 is the last SainSmart UNO development board version. Parameter 3.3V/5V Supply Voltage and IO Voltage can be switched at the same time. More 3.3V modules supported, such as Xbee module, Bluetooth module, RF module, GPRS module, GPS module, LCD5110 Backlight and so on, but the original version can only support 5V IO. Controller uses SMD MEGA328P-AU chip. Add A6/A7 port. 5V Electric current : 500MA 3.3V Electric current : 50MA Input Voltage: 7-12V Improvement of R3 Working voltage 3.3V/5V is optional. Arduino can only work at 5V voltage. When it comes to 3.3V Level module, IO can’t be connected to it. The Level should be changed, like the SD card, Bluetooth module and so on. Sainsmart UNO R3 can work at 3.3V voltage by switching on the button. At this time, IO port is 3.3V and it can work with 3.3V Level module. (R3 can directly use the electronic building blocks on I / O port and elicit G, V, S) Copyright © 2013 SainSmart All Rights Reserved www.sainsmart.com Arduino C Grammar Arduino grammar is built on the basis of C/C + +, in fact is also the basic C grammar, Arduino grammar not only put some related parameters Settings are function change, we have no need to understand his bottom, let us to know AVR micro control unit (MCU) friend can also easy to fit in. So here I'll simple comment the Arduino grammar. Control Structures If if...else for switch case while do... while break continue return goto Further Syntax ; {} // /* */ Operators ++ -- += -= *= /= = + - * / % == != < > <= Copyright © 2013 SainSmart All Rights Reserved www.sainsmart.com >= && || ! Data type boolean char byte int unsigned int long unsigned long float double string array void Constant HIGH | LOW Said digital IO port level, HIGH Said high level(1), LOW Said low electric flat(0). INPUT | OUTPUT Said digital IO port direction, INPUT Said input (high impedance state) OUTPUT Said output (AVR can provide 5 v voltage and ma current). TURE | FALSE true(1) , false(0). All above are the basic c grammar words and symbols, everybody can understand, and the specific use can combine experimental procedure. Structure void setup() The setup() function is called when a sketch starts. Use it to initialize variables, pin modes, start using libraries, etc. The setup function will only run once, after each power up or reset of the Arduino board. void loop() After creating a setup() function, which initializes and sets the initial values, the loop() function does precisely what its name suggests, and loops consecutively, allowing your program to change and respond. Use it to actively control the Arduino board. Function Digital I/O pinMode(pin, mode) pin 0~13, mode is input or output. digitalWrite(pin, value) pin 0~13, value is HIGH or LOW. int digitalRead(pin) pin 0~13, value is HIGH or LOW. Copyright © 2013 SainSmart All Rights Reserved www.sainsmart.com Analog I/O int analogRead(pin) pin 0~5. analogWrite(pin, value) pin 3, 5, 6, 9, 10, 11, value is 0 to 255 Time delay(ms)Pauses the program for the amount of time (in miliseconds) specified as parameter. (There are 1000 milliseconds in a second.)(unit ms). delayMicroseconds(us) Math min(x, y) minimum value max(x, y) maximum value abs(x) absolute value constrain(x, a, b) Constraint function, lower limit a upper limit b, x must be between a & b to be returned map(value, fromLow, fromHigh, toLow, toHigh) pow(base, exponent) extraction of square root sq(x) square sqrt(x) Square root Copyright © 2013 SainSmart All Rights Reserved www.sainsmart.com Chapter 1 Hello World! In this chapter, we will learn use Arduino IDE serial interface tools to show the contents that we want to display in the computer. Example code: void setup() { Serial.begin(9600);// opens serial port, sets data rate to 9600 bps Serial.println("Hello World!"); } void loop() { } Explain: Serial.begin(9600); The comment says 9600 bps, and just so you know bps stands for bits-per-second (we will refer to this as the baud rate). Communicate with computer, you may choose these rate “300, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, 115200”. Operation: 1) Download code to arduino. 2) After download, click “tool”, pick up relevant arduino board, and relevant com. Then click “serial Monitor”, on the new open up window’s bottom right, choose the relevant rate. Copyright © 2013 SainSmart All Rights Reserved www.sainsmart.com Copyright © 2013 SainSmart All Rights Reserved www.sainsmart.com Chapter 2 Blink LED Small LED lamp experiment is the basis of comparison of the experimental one, this time we use the motherboard comes with 13 feet of LED lights to complete the experiment, the experimental equipment we need is the Arduino which each experiment must have and USB download cable. Next we connect small lamp in accordance with the following experimental schematic physical map. Accordance with the good circuit after the link above figure, you can start writing programs, and we let the small LED lights flashing. Lighting on for one second and off for one second. This program is very simple. This is Arduino own routines Blink. Example code: int ledPin = 13; //define pin 13 void setup() { Copyright © 2013 SainSmart All Rights Reserved www.sainsmart.com pinMode(ledPin, OUTPUT);//define interface is output } void loop() { digitalWrite(ledPin, HIGH); //light up led lamp delay(1000); //delay 1s digitalWrite(ledPin, LOW); //go out led lamp delay(1000); // delay 1s } After downloading the program, you can see our 13-foot LED lights flashing, so that our small lights flicker experiment is complete. Copyright © 2013 SainSmart All Rights Reserved www.sainsmart.com Chapter3 LED Blink light emitting diode What’s light emitting diode? The light emitting diode referred to as LED. By gallium (Ga) and arsenic (AS) and phosphorus (P) made of a compound of the diode, when the electron and hole recombination can radiate visible light, and thus can be used to prepare a light-emitting diode in the circuit and the instrument as the indicator, or the composition of the text or digital display. Ga As P diode hair red, gallium phosphide diode green silicon carbide diode yellow. A flashing LED lights experiment Experiment component LED lamp : 1 220Ω resistor : 1 Breadboard & Jumper wires Connect your circuit as the below diagram Copyright © 2013 SainSmart All Rights Reserved
Description: