Start here, Make a project!
This blog shares various useful Projects made by Kuman and Kuman's specially invite writers. If you like, welcome to contribute to us, and get paid.
By Kumantech | 14 August 2017 | 170 Comments

Let Arduino say Hello World

Firstly, let's make a simple project without any peripheral components but an Arduino board. This project makes communication between arudino and PC. It is a gate to access the arduino world.
Supplies needed:
>> Arduino board*1
>> USB cable*1

Arduino board

USB cable

After installing the driver on the arduino board according to the instruction above, open the software of arduino, write a segment program to show "hello world" as soon as the arduino board receiving the command from you, you certainly can make the board show "hello world" without receiving any command. So easy, arduino board will be complied with you by a program statement: if (), we can also use the built-in number 13 pin LED, to make LED twinkle once, then show hello world  

Here is a piece of code for your reference.
//////////////////////////////////////////////////////////
int val;// define variable val
int ledpin=13;// define digital interface 13
void setup()
{
  Serial.begin(9600);//Set baud rate as 9600, it needs to be same as the software. When access specific equipment (e.g. bule tooth),we need to keep the consistent baud rate with other equipments.
  pinMode(ledpin,OUTPUT);//Set digital 13 as output port, Arduino's I/O ports need to be defined like this.
}
void loop()
{
  val=Serial.read();//Read the Arduino command or character and assign to val
  if(val=='R')// Judge if received command or character is "R"
  {  //if it is "R"
    digitalWrite(ledpin,HIGH);// Light up the digital 13 port LED
    delay(500);
    digitalWrite(ledpin,LOW);// turn off the digital 13 port LED
    delay(500);
    Serial.println("Hello World!");//show hello world
  }
}
////////////////////////////////////////////////////////////////

Diagram:


Click tool-serial port monitor


Input R
LED twinkle once
Receive the information hello world from arduino


Notice: choose right COM port, otherwise you can not receive the data, the below is COM port selection.

 

 

Recently Reviews

Read More

Leave a Reply

Your email address will not be published.Required fields are marked. *
Name
E-mail
Content
Verification code
POPULAR BLOG