You are on page 1of 49

SunFounder

ArduBlock graphical programming kit


--- For Arduino

ArduBlock zero base programming package recently launched a Arduino-based graphical programming enthusiasts learning packages, greatly reduces the learning curve for enthusiasts, all programming are available through the building-block approach to high-level computer language and professional grammar, simplified as a module, piled together. Finally, and interactive Arduino Development Boards to make exciting effect.

n Su

u o F

r e d n

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder
Arduino open source characteristics, making her support of a large number of fans on the Internet, there have been a lot of learning communities. As ArduBlock are the building blocks of programming, largely reducing the threshold of learners do not need specialized knowledge, no engineering background, as long as you like, you can play. Especially now that the great emphasis on training the next generation of people, this is for you and your child one of the best ways to parent-child interaction.

ArduBlock zero base programming package list: 1. 6XQ)RXQGHU UNO R3 development board * 1 2 sensor expansion board * 1 3 white LED module * 1 4 red LED module * 1 5 Yellow LED module * 1 6 Green LED module * 1 7 buzzer module * 1 8LM35 temperature sensor * 1 9 light sensor * 1 10 Sound Sensor * 1 11 rotary potentiometer module * 1 12 button module * 1 13 Ultrasonic Ranging Module * 1 14XY joystick module * 1 159 g servos * 1 163PIN sensor cable * 5 17 DuPont lines * 20 18USB cable * 1

n Su

u o F

r e d n

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder
1.Arduino 0icrocontroller Introduction

Arduino is derived from the Italian open source hardware projects a platform that includes a with a simple I / O functions of the circuit board and a set of application development environment software. Arduino can be used to develop interactive products, such as it can be read by a large number of switches and sensor signals, and can control lights, motors, and other kinds of physical devices; Arduino can also develop peripheral devices connected to the PC, can on the PC running the software to communicate.

n Su

u o F

r e d n

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder

Arduino-driven installation and programming process: The experiment with the development board is 6XQ)RXQGHU UNO R3 development board, fully compatible with the official version. See physical map:

n Su

u o F

r e d n

Let's download the Arduino development software, web address: http://arduino.cc/en/Main/Software Downloaded arduino-1.0.zip file is a compressed folder, extract it to your hard drive. The 6XQ)RXQGHU UNO R3 development board via a USB cable to connect to Windows, you will be prompted with named "Arduino UNO R3" New USB device found

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder
Then Windows will guide us into the "Found New Hardware Wizard" window, select one of the "No, not this time" and click "Next" button: The next step you need to install the required drivers 6XQ)RXQGHU UNO R3, select one of the "Install from a list or specific location (Advanced)" option and click "Next" button:

SunFounder UNO R3 drivers on Arduino 1.0 drivers directory under the installation directory, we need to specify the directory where you installed Windows when driven search directories: Click the "Next" button, Windows will begin to find and install the Arduino drivers: If everything is normal, then we will see the following success screen:

Arduino driver installation is successful, we can in the Windows Device Manager, find the corresponding Arduino serial port:

************************************************** ****************************

n Su

u o F

r e d n

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder

2.ArduBlock Introduction

Designed for the Arduino a graphical programming software, created by the Shanghai New customer development workshop. ArduBlock official Arduino programming environment software is third-party software, must be attached to the Arduino software currently running, the text distinguishes Arduino programming environment, ArduBlock is the way to build a graphical programming blocks, in such a way makes visualization and programming Interactivity enhanced programming threshold is reduced, even without programming experience can also try to Arduino controller programming.

n Su

u o F

r e d n

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder
On the right is the image programming, left is to generate the C language, if you do not know C language, graphics, you should know it!

The figure is a flashing led program

The following analysis of the program Main do -> loop {set a pin high -> Delay 1 second -> Set an output pin low -> Delay 1 second.} If you are a master, please avoid: Graph corresponding C language void setup () { pinMode (1, OUTPUT); } void loop () { digitalWrite (1, HIGH); delay (1000); digitalWrite (1, LOW); delay (1000); }

n Su

u o F

r e d n

************************************************** ***************************** Interest to the bar and immediately installed. Download: http://cloud.github.com/downloads/taweili/ardublock/ardublock-all.jar

First download, open Arduino1.0, click File, then click Perferences (Figure)

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder

We can see the pop-up box, remember the following this path (Figure)

n Su

u o F

r e d n

D: \ My Documents \ Arduino \ tools \ ArduBlockTool \ tool

Look into your folder there is no such path, if no folder has been created, and then put back archive you downloaded (in fact, JAVA software) replication in the final folder inside the

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder
installation is complete.

Open the Arduino 1.0 development environment, Tools-> ArduBlock This option is (not the original)

n Su

u o F

r e d n

************************************************** *************************

That ArduBlock exactly how to use it? ArduBlock modules are divided into different categories. "Control" zone is a function of control structures. (1) Control

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder

2.PIN feet

n Su

u o F

r e d n

These modules can be in your Arduino template as a virtual pin. 3 numbers, constants and variables

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder
4 op

This project includes logical and mathematical operations 5 Common Commands

n Su

u o F

r e d n

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder

These are commonly used in programming. 6 modules

Each module represents a direct use of hardware, it can be directly used as part of your hardware. ************************************************** *****************************

n Su

u o F

r e d n

3 experimental courses
Here we should Arduino and ArduBlock have a preliminary understanding, we are following through hands-on learning of this graphical programming software.

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder
Ardublock zero-based programming routines 1 LED flashes experiments
LED lights are more basic experimental one experiment, we used bright LED light modules to complete the experiment. Apparatus as follows: Arduino compatible development board SunFounder uno R3 * 1 Arduino IO port expansion board V5 * 1 Bright LED light module * 1 3PIN sensor cable * 1 Small light experiment schematics

n Su
Physical map

u o F

r e d n

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder
Good link circuit according to the diagram, you can start writing programs, and we still make LED lights flashing, lit one second off one second. This procedure is very simple and comes with Arduino Blink similar routines where just 13 digital interface for doing 10 digital interface.

A good job, then click download to ARDUINO, ARDUINO programming interface code will appear ************************************************** *************************** void setup () { pinMode (10, OUTPUT); } void loop () { digitalWrite (10,! (HIGH)); delay (1000); digitalWrite (10,! (LOW)); delay (1000); }

n Su

u o F

r e d n

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder

Then we can see that we have received IO port 10 feet flashing bright LED lamp module, so our little lights flashing experiment is complete. ************************************************** ***************************** Note: Arduino development software choice TOOLS bar board option is UNO, To select the initial installation of the communications port serial appears Two indispensable, or can not download the program. ************************************************** *****************************

Ardublock zero-based programming routines 2 PWM Dimming

PWM (Pulse-width modulation) pulse width modulation PWM is controlled using digital means to a means of the analog output. Using digital control generates different duty cycle square wave (a constant switching between on and off signals) to control the analog outputs. Generally port input voltage is only two 0V and 5V. If I want my output voltage of 3V how to do. . . Some students said that the series resistance, right, this method is correct drops. But if I want to 1V, 3V, 3.5V, and so forth between changes in how to do it? Impossible to keep it switched resistor. In this case. . . You need to use a PWM. How he controls it, the digital port for arduino LOW and HIGH voltage output only two switches, the corresponding voltage is 0V and 5V output, we present the LOW is defined as 0, HIGH is defined as 1 to a second arduino 500 outputs a signal of 0 or 1. If this is all for a 500, it is a complete 5V, if all is 0, that is 0V. If 010101010101 so that the output, just half and half, the output port on the feeling is the voltage output of 2.5V. This is a screening of the film, and we reason, we have to see the movie is not completely continuous, it is actually output 25 pictures per second, in this case is the servant can not be seen to the naked eye, it looks like that is a continuous . PWM is the same reason, if you want different voltages between 0 and 1 on the control of the output of proportional control is ok ~ course. . . This is true there are still differences of continuous output, output per unit time of 0,1 signal, the more control the more accurate.

n Su

u o F

r e d n

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder

In the following figure, the green line represents a cycle between, and its value is the reciprocal of the PWM frequency. In other words, if the arduino PWM frequency is 500Hz, then the period between two green lines is two milliseconds. analogWrite () command can be controlled in the range of 0-255, analogWrite (255) indicates a 100% duty cycle (normally open), analogWrite (127) duty cycle of about 50% (half the time).

The experiment is controlled via a PWM LED lights brighten and then slowly let it slowly darken, so the cycle. Similarly, we still put bright LED module to the digital IO port pin 10, the following is a wiring diagram:

Let Programming:

n Su

u o F

r e d n

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder

Similarly, we still click (download to ARDUINO), see the code generated by IDE interface ************************************************** ********************** int _ABVAR_1_brightness; void setup () { _ABVAR_1_brightness = 0; } void loop () { while (((_ABVAR_1_brightness) <(255))) { _ABVAR_1_brightness = (_ABVAR_1_brightness + 1); analogWrite (10, 255 - (_ABVAR_1_brightness)); delay (5); } while (((_ABVAR_1_brightness)> (0))) { _ABVAR_1_brightness = (_ABVAR_1_brightness - 1); analogWrite (10, 255 - (_ABVAR_1_brightness)); delay (8); }

n Su

u o F

r e d n

delay (200); } ************************************************** ***************************** So the way we use the graphical programming the LED slowly fades as breathing, so we gave it a magical name, breathing light.

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder
Ardublock zero-based programming routines 3 traffic lights design experiments
Above we have completed a single small light control experiment, then we do a little more complicated traffic light experiments, in fact, clever friends can see out of this experiment is to test a single small light above experiments extended to three colors The small lights, you can achieve our experiment simulated traffic lights. We accomplish this experiment required components in addition to Arduino compatible controller and the download cable is also required hardware is as follows: Red LED module * 1 Yellow LED module * 1 Green LED module * 1 3PIN cable * 3 Ready we can start these components, we can follow the above experimental replicability of small lights flashing, here is that we provide reference schematics, respectively, we use digital 10,7,4, interface.

n Su

u o F

r e d n

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder
Since it is a traffic light simulation experiments, a small red-yellow-green lights flashing time will simulate real traffic lights, We use the Arduino delay () function to control the delay time relative to the C language would simply many of the. Let Programming:

n Su

u o F

r e d n

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder

Click (download to ARDUINO), we can see that the IDE appears the following code: / / ***************************** void setup () { pinMode (10, OUTPUT); pinMode (4, OUTPUT); pinMode (7, OUTPUT); } void loop () { digitalWrite (4, LOW); digitalWrite (7, LOW); digitalWrite (10, HIGH); delay (1000); digitalWrite (4, LOW); digitalWrite (7, HIGH); digitalWrite (10, LOW); delay (200); digitalWrite (4, HIGH); digitalWrite (7, LOW); digitalWrite (10, LOW); delay (1000); } } ************************************************

/ / ************************************************ ******************************

n Su

u o F

r e d n

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder

************************************************** ***************************** Complete the download process can be seen after the traffic control of our own design

Ardublock zero-based programming routines 4 keys to control LED

Control buttons are a commonly used electrical components, used to turn on or off the circuit, so as to control operation of the motor or other device switch. The experimental use buttons to control the led light or off. The general situation is directly to the key switch in series with the circuit led to the switch, this application is relatively simple. The experiment is controlled by indirect methods, determine the key after key is turned in the circuit output voltage, if the voltage is greater than 4.88V, the LED on the circuit output is high, and vice versa on the output low. Use logic to determine methods to control the LED light or off, this control method wide range of applications. Components needed to complete this experiment in addition Arduino compatible controller and download cable is also required hardware is as follows: White LED module * 1 Key module * 1 3PIN Cable * 2

n Su

u o F

r e d n

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder
Experimental diagram:

Let Programming:

n Su

u o F

r e d n

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder
Click (download to ARDUINO), we can see that the IDE appears the following code: / / ************************************************ ***************************** void setup () { pinMode (10, OUTPUT); pinMode (4, INPUT); } void loop () { if ((digitalRead (4) && HIGH)) { digitalWrite (10,! (HIGH)); delay (50); } else { digitalWrite (10,! (LOW)); delay (50); } }

************************************************** ***************************** ************************************************** ***************************** After the completion of the download process can use the keypad to control LED lights up.

n Su

u o F

r e d n

Ardublock zero-based programming routines 5 buzzer

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder
experiments
Arduino can be done with a lot of interactive work, the most common and most commonly used is the sound and light show in front has been in use LED lights in the experiment, the experiment let everyone circuit sound, with a voice The most common is the buzzer and speaker components, the comparison of the two buzzer easier and ease the present study, we buzzer. The following components are to be prepared: Buzzer module * 1 3PIN Cable * 1 Connection diagram:

n Su

u o F

r e d n

Connect the circuit to the attention of the positive and negative point is that the buzzer of the points, can be seen below on the right physical map buzzer red and black two wiring. Connect the circuit program in this regard is very simple, with small lights front control buttons experimental procedure is similar because of the buzzer output control interface Digital interface also can control the high and low buzzer sounds.

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder
Let Programming:

n Su
*****************************

u o F

r e d n

Click (download to ARDUINO), we can see that the IDE appears the following code:

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder

************************************************** **************************** After downloading the program, the buzzer experiments are done.

n Su

u o F

r e d n

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder
analog value read

Ardublock zero-based programming routines 6 experimental

In this study, we have to start learning about analog I / O interface to use Arduino with Analog 0 - Analog 5 Total 6 analog interfaces, which six interface can also be counted as multiplexed interface functions, in addition to analog interface functions, which 6 can be used as a digital interface to use interfaces, numbered numeral 14 - the number 19, simple understanding after following on to start our experiment. Potentiometer is more familiar typical analog value output element, the experiment will be done with it. Required components are: Potentiometer module * 1 3PIN Cable * 1 In this study, we will be the resistance of the potentiometer into analog value is read out, and then displayed on the screen, which is why we need to complete their subsequent experimental features examples of applications that must be mastered. We need the following diagram to connect the physical map

n Su

u o F

r e d n

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder
We are using an analog 0 interface. Procedures for the preparation is very simple, a analogRead (); statement can be read out analog port values, Arduino 328 is a 10-bit A / D acquisition, so the read analog value range is 0-1023, the experimental procedure There is also a difficulty value is displayed on the screen this problem, it is very simple to learn. First, we want to voidsetup () which set the baud rate, the indicated value is Arduino communicate with the PC, so the Arduino software and PC baud rate should be set in the same order to show the correct value, otherwise it will be garbled or does not appear in the lower right corner of the monitor window of Arduino software has a button that you can set the baud rate, the baud rate set here need to talk program void setup () which set the baud rate the same procedure to set the baud rate of the statement is Serial.begin (); including No value for the baud rate. The second is a statement of the displayed value, Serial.print (); or Serial.println (); all OK, unlike the latter value End show automatically after carriage return, the former is not, to explain more about the statement in front of

Introduced here is not to say more, we have to write the program:

n Su

u o F

r e d n

Click (download to ARDUINO), we can see that the IDE appears the following code: / / ************************************************ ***************************** void setup () { Serial.begin (9600); }

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder
void loop () { Serial.print ("value:"); Serial.print (analogRead (A0)); Serial.println (""); delay (1000); } ************************************************** ********* Here is read analog values. This experiment is done here, when you turn the potentiometer knob when you can see the changes in the value on the screen, read the analog value of this method will always accompany us, the analog value is read very frequently used functions, as Many sensors are analog value output, we read the analog value, and then the corresponding algorithm processing, can be applied to the functions we need to implement in the.

Ardublock zero-based programming routines 7 experimental sound and light control


Photoresistor (photovaristor) also known as light-sensitive resistor which is made of the use of the photovoltaic effect of a resistance value changes with the intensity of incident light resistor; incident light intensity, the resistance decreases, the incident light is weak, the resistor increases. Light sensitive resistor is generally used for measurement, control and photoelectric conversion of light (the change of the light is converted to electrical change). Photoresistor can be widely used in various light control circuit, such as lighting control, regulation and other occasions, also be used for light control switch. In this experiment we first conduct a relatively simple experiment using photoresistors 1, the experimental device photoresistor modules: 1 Buzzer Module: 1

n Su

u o F

r e d n

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder
3PIN Cable * 2 2, the experimental connection

n Su
3, the experimental principle Let Programming:

u o F

r e d n

The application process preceding sections read analog port voltage value method photoresistor connected directly to the digital port. When there is light, the photosensitive resistor decreases, the buzzer does not sound. Block photoresistor module, the normal sound,

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder

Click (download to ARDUINO), we can see that the IDE appears the following code: / / ************************************************ ***************************** int _ABVAR_1_val; void setup () { _ABVAR_1_val = 0; Serial.begin (9600); pinMode (10, OUTPUT); }

n Su

u o F

r e d n

void loop () { _ABVAR_1_val = AnalogRead (A0); Serial.print ("light:"); Serial.print (_ABVAR_1_val); Serial.println (""); if (((_ABVAR_1_val) <= (50))) { digitalWrite (10, HIGH); delay (1000); }

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder
else { digitalWrite (10, LOW); delay (1000); } } **************************************************

Master the program, we can design experiments yourself, you can also use photoresistor control led lamp brightness.

n Su

u o F

r e d n

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder
Ardublock zero-based programming routines 8 voice light experiment
Sound sensor is used to ambient sound level in the detection, can be used to detect the intensity of the sound and the output voltage is proportional to. Analog sensors only need a dedicated data line, it can be used with Arduino sensor expansion board combination, very easy to achieve sound perception associated with interactive effects. Operating voltage: +3.3 / 5V, Interface Type: Analog, current: <10mA. After completion of the above, various experiments, we Arduino application should also have some knowledge and understanding, and in the basic digital inputs and outputs and analog inputs are controlled PWM generation later, we can begin to make some sensor applications the. The following are the required components: Sound Module * 1 Bright LED module * 1 Sensor cable * 2 Connect the circuit according to the following diagram.

n Su

u o F

r e d n

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder
Connect can write programs, and

n Su

u o F

r e d n

Click (download to ARDUINO), we can see that the IDE appears the following code: / / ************************************************ ***************************** int _ABVAR_1_sound_value; int _ABVAR_2_;

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder
void setup () { _ABVAR_1_sound_value = 0; Serial.begin (9600); } void loop () { _ABVAR_1_sound_value = 0; for (_ABVAR_2_ = 0; _ABVAR_2_ <(100); + + _ABVAR_2_) { _ABVAR_1_sound_value = (_ABVAR_1_sound_value + AnalogRead (A0)); } analogWrite (11, 255 - (map (_ABVAR_1_sound_value, 0, 1024, 0, 255))); Serial.print ("sound val:"); Serial.print (_ABVAR_1_sound_value); Serial.println (""); } ************************************************** **************************** After downloading the program we look at the value of serial monitoring

Sound modules measured against the value of blowing, you can see there is a corresponding LED lights change. Sound modules in everyday life is a very broad application, usage is a lot, we can root According to this experiment, by analogy, to make better interactive work.

n Su

u o F

r e d n

Ardublock zero-based programming routines 9 servo control

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder
experiments
A position servo servo drive, mainly by the housing, a circuit board, coreless motors, gears and the position detector of the composition. Its working principle is the microcontroller sends a signal to the receiver or servos, which has an internal reference circuit, resulting in a period of 20ms, the width of 1.5ms reference signal will get the DC bias voltage and the potentiometer voltage comparator, access differential voltage output. Judgment of the IC via the circuit board the direction of rotation and then starts rotating non-core motor drive, the power transmitted through the reduction gear arm, and back to the signal from the position detector to determine whether the positioning has been reached. For changing the angle and that require a control system can be maintained. When the motor speed is constant, the reduction gear driven by cascading rotary potentiometer so that the voltage difference is 0, the motor stops rotating. General steering angle of rotation range is 0 to 180 degrees.

There are many standard servos, but all the servos have an external three lines, respectively, with brown, red, orange and three colors to distinguish, because servos different brands, colors will vary, brown is the ground wire, red for positive power supply line, orange for the signal lines. Angle of rotation of the servo by adjusting the PWM (pulse width modulation) signal duty cycle to be achieved, standard PWM (pulse width modulation) signal period is fixed at 20ms (50Hz), in theory, should be distributed at 1ms pulse width to between 2ms, but, in fact, be 0.5ms to 2.5ms pulse width between pulse width and servo corner 0 ~ 180 correspond. It is worth noting the place, because servos different brands, for the same signal, different brands of servo rotation angle will be different.

n Su

u o F

r e d n

After understanding the basics since we can learn to control a servo, and this experiment need only servos a few components, jumpers a bundle on it. RB-412 servos * 1

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder

Breadboard Jumper * a tie Arduino control with steering in two ways, one is through the Arduino ordinary digital sensor interface produce different duty cycle square wave, analog servo positioning generate a PWM signal, the second is the direct use of Arduino comes Servo function steering control, this control method has the advantage of programming, the disadvantage is only control two-way steering, because Arduino own function only use digital 9,10 interface. Arduino drive capability is limited, so when you need to control one or more servos require an external power supply. Here we have a module control via potentiometer rotation servos Use Original: arduino board * 1 Potentiometer module * 1 9 g servos * 1 Sensor cable * 1 Here we must be careful not to use the computer usb power supply, because if the current demand is greater than 500ma, usb may be burned, it is recommended to use an external battery powered.

n Su
Let Programming:

u o F

r e d n

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder

A good job, then click (download to ARDUINO), ARDUINO programming interface code will appear ************************************************** *************************** # Include <Servo.h> int _ABVAR_1_val; int _ABVAR_2_servo; Servo servo_pin_9;

n Su

u o F

r e d n

void setup () { _ABVAR_1_val = 0; servo_pin_9.attach (9); _ABVAR_2_servo = 0; } void loop () { _ABVAR_1_val = AnalogRead (A0); _ABVAR_2_servo = Map (_ABVAR_1_val, 0, 1023, 0, 180); servo_pin_9.write (_ABVAR_2_servo); }

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder
************************************************** Burn development board inside the program, we can use a potentiometer control servos.

Ardublock zero-based programming routines 10 Ultrasonic Ranging


We look first to understand ultrasonic module

n Su

u o F

r e d n

1, HC-SR04 module performance is stable, measure the distance accurately, is the highest price the market ultrasonic module, the module can be realized 2cm-4.5m non-contact distance

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder

measurement capabilities, with 2.4-5.5V wide voltage input range, static consumes less than 2mA, comes with a temperature sensor for correction ranging results, but also has GPIO, serial, and other means of communication, which with the watchdog, stable and reliable.

2, the main technical parameters: 1) Use voltage: DC5V 2) Static current: less than 2mA 3) level output: high-5V Low 0V 4) Serial output: 9600 baud, 1 start bit, 1 stop bit, 8 data bits, no parity, no flow control. 5) Sensor angle: not more than 15 degrees 6) Detection distance: 2cm-450cm 7) Precision: 0.3cm +1% 8) board size 20 * 45 * 1.6mm

3 Wiring: VCC, trig (control side) / TXD, echo / RXD (receiving end), GND.

4 Usage: 10US a control population made a high of more than, you can wait to receive high output port. A timer can be opened with the output timing, when this port goes low when you can read timing The value of this time on time for this distance, only calculate the distance. This constant cycle of measurement, you can reach the value of the mobile measurement ~ ~

5 Module works: Only need Trig / TX pin input a high of more than 10US, the system may issue 8 40KHZ ultrasonic pulse, and then detect the echo signal. When the echo signal is detected, the module also for temperature measurement, and then the ranging result of the current temperature correction, the corrected results by Echo / RX pin output. In this mode, the module into the distance value is 340m / s when the time value of 2 times, a high level side output by Echo, according to the duration of this high value to calculate the distance. Ie, the distance values are: (High Time * 340m / s) / 2. Note: Because the distance value temperature correction has been, at this time no longer according to the ambient temperature on the ultrasonic sound velocity correction, that no matter how much the temperature, velocity selection 340m / s can be. Let's experiment, first press the figure's identity, the ultrasonic connected to ARDUINO,

n Su

u o F

r e d n

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder
Look real connection diagram

Connect Well, we started programming:

n Su

u o F

r e d n

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder
A good job, then click download to ARDUINO, ARDUINO programming interface code will appear ************************************************** *************************** int ardublockUltrasonicSensorCodeAutoGeneratedReturnCM (int trigPin, int echoPin) { int duration; pinMode (trigPin, OUTPUT); pinMode (echoPin, INPUT); digitalWrite (trigPin, LOW); delayMicroseconds (2); digitalWrite (trigPin, HIGH); delayMicroseconds (5); digitalWrite (trigPin, LOW); duration = pulseIn (echoPin, HIGH); duration = duration / 59; return duration; } int _ABVAR_1_t1;

void setup () { Serial.begin (9600); digitalWrite (4, LOW); _ABVAR_1_t1 = 0; }

n Su

u o F

r e d n

void loop () { _ABVAR_1_t1 = ArdublockUltrasonicSensorCodeAutoGeneratedReturnCM (4, 5); Serial.print ("distance:"); Serial.print (_ABVAR_1_t1); Serial.println (""); delay (1000); }

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder

************************************************** *************************** Download a good program we can see in ARDUINO serial surveillance ultrasonic distance measurement values

Ultrasound can be clearly felt by hand block value changes

Well, this section is on here, we can use your imagination, the ultrasound is applied to other design go above.

Ardublock zero-based programming routines 11 PS2 joystick module

n Su

u o F

r e d n

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder
First, the product description The company produces PS2 game joystick axis sensor module consists of using original quality metal PS2 joystick potentiometer system For, with (X, Y) 2-axis analog output, (Z) 1 digital output channel button. With Arduino sensor expansion board can be made For remote control and other interactive work. In addition the product in order to allow customers to more easily fit arduino expansion boards and other standard interfaces Mouth, in the design of the X, Y, Z-axis circuit leads individually, you can use three pin ARDUINO dedicated line directly into the expansion board for use. It is convenient. Second, product characteristics It is like a game console joystick, you can control the joystick module input x, y, z of Values, and to achieve a particular value in a function, it can be considered a combination of buttons and a potentiometer. Data Type of x, y dimension for the analog input signal is a digital input signal z dimension, therefore, x and y connected to the analog port Pin sensor end, and z port is connected to the digital port.

Third, the use On how to use, we first look at how it works now, so we know it is there in the end How, which we find it helpful to use, there is a functional diagram below, we take a look Now we should clear it, in fact, it is a potentiometer Well, x, y dimension of the data output is analog Port readout voltage value, is not a little surprised. Of course, this is not shown above, zdimensional data output, in fact, it is more Simple, we know that z-dimensional output only 0 and 1, then it can be achieved through a button bar. Now on we should Surface of saying, it is a potentiometer and button combination (To be honest, if you do not understand it just to see that Sentence is a bit foggy it? ).

n Su

u o F

r e d n

After reading the chart I believe we all know how to use it right Arduino, x, y dimension we received two analog ports Read their values, z dimension we are to the digital port, and so on the line, plus the power and ground, so fine. . . .

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder
Fourth, the module test Let's look at this test what things we have, in fact, not much. . . . Arduino controller 1 USB data cable 1 Joystick Module 1 Here x I connected an analog port 0, y even an analog port 1,

Even a good circuit, now we come Programming:

n Su

u o F

r e d n

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder

Fourth, the module test Let's look at this test what things we have, in fact, not much. . . . Arduino controller 1 USB data cable 1 A good job, then click download to ARDUINO, ARDUINO programming interface code will appear ************************************************** *************************** int _ABVAR_2_y; int _ABVAR_1_x; void setup () { _ABVAR_2_y = 0; Serial.begin (9600); _ABVAR_1_x = 0; } void loop () { _ABVAR_1_x = AnalogRead (A0); _ABVAR_2_y = AnalogRead (A1); Serial.print ("x:"); Serial.print (_ABVAR_1_x); Serial.println (""); Serial.print ("y:"); Serial.print (_ABVAR_2_y); Serial.println (""); delay (500); }

n Su

u o F

r e d n

************************************************** **************************** Download a good program we can see in ARDUINO serial surveillance joystick module X-axis and Y-axis values

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder
Hand shake joystick module X-axis and Y-axis, we can clearly see that the number of changes The introduction of the game joystick module on to this, in fact, use it to make a pretty good thing, we can enjoy the Imagination.

Ardublock zero-based programming routines 12 LM35 temperature sensor experiment

LM35 is a very common and easy to use temperature sensor element, the components need only one application LM35 components, using only an analog interface can be, on the difficulty lies in the algorithm will read the analog value is converted to the actual temperature. Connect the circuit according to the following diagram.

n Su

u o F

r e d n

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder

Let Programming:

n Su

u o F

r e d n

A good job, then click download to ARDUINO, ARDUINO programming interface code will appear ************************************************** *************************** int _ABVAR_2_dat;

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

SunFounder
int _ABVAR_1_val; void setup () { _ABVAR_2_dat = 0; _ABVAR_1_val = 0; Serial.begin (9600); } void loop () { _ABVAR_1_val = AnalogRead (A0); _ABVAR_2_dat = ((5 * _ABVAR_1_val) / 10); Serial.print ("TEMP ="); Serial.print (_ABVAR_2_dat); Serial.println (""); delay (100); }

************************************************** Download a good program we can see the current ARDUINO serial monitor the temperature of the

n Su

u o F

r e d n

Above is our finishing Ardublock zero-based programming 12 routines, of course, there are many applications ARDUINO, we hope to learn communication ************************************************** ****************************

SunFounder Products

http://www.amazon.com/s/ref=bl_sr_pc?_encoding=UTF8&field-brandtextbin=SunFounder&node=172282

You might also like