
www.keyestudio.cc
4
4. Project details
Project 1: Hello World
Introduction
As for starters, we will begin with something simple. In this project, you only need an Arduino and a
USB cable to start the "Hello World!" experiment. This is a communication test of your Arduino and
PC, also a primer project for you to have your first try of the Arduino world!
Hardware required
1. Arduino board x1
2. USB cable x1
Sample program
After installing driver for Arduino, let's open Arduino software and compile code that enables Arduino
to print "Hello World!" under your instruction. Of course, you can compile code for Arduino
to continuously echo "Hello World!" without instruction. A simple If () statement will do the
instruction trick. With the onboard LED connected to pin 13, we can instruct the LED to blink first
when Arduino gets an instruction and then print "Hello World!”.
//////////////////////////////////////////////////////////
int val;//define variable val
int ledpin=13;// define digital interface 13
void setup()
{
Serial.begin(9600);// set the baud rate at 9600 to match the software set up. When connected to a
specific device, (e.g. bluetooth), the baud rate needs to be the same with it.
pinMode(ledpin,OUTPUT);// initialize digital pin 13 as output. When using I/O ports on an
Arduino, this kind of set up is always needed.
}
void loop()
{
val=Serial.read();// read the instruction or character from PC to Arduino, and assign them to Val.
if(val=='R')// determine if the instruction or character received is “R”.
{ // if it’s “R”,
digitalWrite(ledpin,HIGH);// set the LED on digital pin 13 on.
delay(500);
Содержание Basic starter kit
Страница 1: ...1 ...
Страница 10: ...keyestudio www keyestudio cc 8 Connection for 2560 R3 ...
Страница 17: ...keyestudio www keyestudio cc 15 Connection for 2560 R3 ...
Страница 21: ...keyestudio www keyestudio cc 19 Connection for 2560 R3 ...
Страница 25: ...keyestudio www keyestudio cc 23 Connection for 2560 R3 ...
Страница 29: ...keyestudio www keyestudio cc 27 Connection for 2560 R3 ...
Страница 39: ...keyestudio www keyestudio cc 37 Connection for 2560 R3 ...
Страница 43: ...keyestudio www keyestudio cc 41 Connect the sensor to analog pin 0 Connection for R3 Connection for 2560 R3 ...
Страница 62: ...keyestudio www keyestudio cc 60 Connection for 2560 R3 ...
Страница 66: ...keyestudio www keyestudio cc 64 Connection for 2560 R3 ...
Страница 77: ...keyestudio www keyestudio cc 75 Manual for LED segment display ...
Страница 78: ...keyestudio www keyestudio cc 76 Connection for R3 Connection for 2560 R3 ...
Страница 90: ...keyestudio www keyestudio cc 88 Connection for 2560 R3 ...
Страница 94: ...keyestudio www keyestudio cc 92 ...
Страница 95: ...keyestudio www keyestudio cc 93 Connection for R3 Connection for 2560 R3 ...