Hello Arduino Experiment MODULE 4
Hello Arduino Experiment MODULE 4
Introduce to Arduino
A programmer loves calligraphy after retirement, one day, he is suddenly in aesthetic
mood after meal, so he prepares "the Four Treasures of Study",writing brush, ink stick, ink
slab and paper, grinds ink, spreads paper and lights a good sandal, quite a Wang Xizhi
demeanor and Yan Zhenqing manner. Composed for a moment, then he splashed ink,
Earnestly writes down the words: "hello world!". Why programmers are so keen on this words?
The inception of "Hello world" dates back to 1972, Bell Laboratory’s famous researcher Brian
Kernighan firstly used it(program) when he was writing "B Language tutorials and guidance
(Tutorial the Introduction to the Language B)" , this is the earliest known record at present
when "hello" and "world" are used together in a computer work . Then, in 1978, he used this
sentence pattern "hello, world" again in C Language bible "The C Programming Language" ,
co-authored with Dennis Ritchie, as the first program in the opening ceremory . In this
program, the output of the "hello, world" are all lower-case, without an exclamation point, a
comma followed by a space. Although the initial form almost failed to survive after that, from
then on, "hello, world" became a tradition of the program world to greet the outside. "Hello
Arduino!", without exception, also became the first program in the tutorial.
Hardware Connection
There is a Atmega16u2 USB serial port on Arduino uno board , so the first program
doesn't need to connect to other equipments, only requires Arduino UNO to connect PC with
a USB cable directly.
Code
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println("Hello Arduino !");
delay(1000);
}
3
Figure 3.1.4 upload program
4) start uploading the program, wait for a while, and there will be a prompt of "successful
uploading" in the lower left corner, showing that the program has been successfully
recorded.See figure 3.1.6.
4
figure 3.1.6 burning is completed
5) open the serial port monitor, as shown in figure 3.1.7 and figure 3.1.8, and set the baud
rate to 9600 (the baud rate should be consistent with the code,Otherwise, the printing
contents will appear garbled code), and you will see the serial port end continuously print
"Hello Arduino!
5
Figure 3.1.7 serial monitor switch
6
Mblock graphical programming program
Programming a serial port print Hello Arduino with mBlock!The program is shown in the
following figure:
Figure 4.1.1