Showing posts with label serial port. Show all posts
Showing posts with label serial port. Show all posts

Controlling LEDs With PC Using Arduino

By // 1 comment:
Wireless communication plays a very important role within the communication system. We may be able to send data from one point to another point simply through wireless communication. There is such a large option available for the wireless communication like Bluetooth, Wi-Fi etc. In this article, we concern only in Bluetooth. Bluetooth is a standard wireless technology which transfers the information over very short distances. It is assumed that you just ought to knowledge to How To Send Serial Data From Arduino To Laptop or PC and How To Receive and Send Serial Data Using Arduino Board

Controlling led via PC/Laptop

After Reading this article you will be able to control LED via your PC/Laptop. For controlling the led we use arduino board Introduction to Arduino Board

Circuit diagram:

Here we use three led blue, green and red that are connected to pin no. 10,9 and 8 of arduino board respectively. We also connect an LCD display module to arduino board. read this post for Interfacing LCD With Arduino UNO. All other connection for controlling led via PC is shown below image

circuit diagram for led control
Circuit Diagram
Program:

// ProjectsDunia
// http://projectsdunia.blogspot.in
// Our Facebook Page http://facebook.com/projectsdunia

//  control LED with your PC


#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int blue_led=10;
int green_led=9;
int red_led=8;
int store=0;
void setup()
 {
    // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  // initialize the serial communications:
  Serial.begin(9600);
  pinMode(blue_led, OUTPUT);
  pinMode(green_led, OUTPUT);
  pinMode(red_led, OUTPUT);
  }
void loop()
{
  // when characters arrive over the serial port...
  if (Serial.available()) 
  {
    // save the data 
    store=Serial.read();
    switch(store)
    {
      case '1':
      lcd.clear();
      digitalWrite(blue_led,HIGH);
      lcd.write(" Blue_LED ON ");
      break;
      case '2':
      lcd.clear();
      digitalWrite(blue_led,LOW);
      lcd.write(" Blue_LED OFF ");
      break;
      case  '3':
      lcd.clear();
      digitalWrite(green_led,HIGH);
      lcd.write(" Green_LED ON ");
      break;
      case '4':
      lcd.clear();
      digitalWrite(green_led,LOW);
      lcd.write(" Green_LED OFF ");
      break;
      case '5':
      lcd.clear();
      digitalWrite(red_led,HIGH);
      lcd.write(" Red_LED ON ");
      break;
      case '6':
      lcd.clear();
      digitalWrite(red_led,LOW);
      lcd.write(" Red_LED OFF ");
      break;
      
    }
  }
}
  
Download:

LED control file

Video:



If you have any question, leave a comment below, Thanks for reading this article.If you like this article then support us by subscribing our youtube channel and like our facebook page.


How To Receive and Send Serial Data Using Arduino Board

By // No comments:
Serial communication is the easiest way to communicate with the peripheral device in embedded system. Thus, during this article, you may be able to learn the way to receive and send serial data from the arduino board. If you are beginner then first read this Introduction to Arduino Board and How To Send Serial Data From Arduino To Laptop or PC before moving on this article.
serial communication virtual terminal monitor
Arduino ide has such a big amount of inbuilt function for serial communication and detail of some function are here  How To Send Serial Data From Arduino To Laptop or PC. During this article, we tend to use some additional function that facilitates us to receive the serial data from the serial port. These functions are Serial.available(), Serial.read(), Serial.write whose explanation are given below:

1: Serial.available()

This function is always used before the Serial.read() function. This function returns always a positive value once reception is complete. This function is used for whether or not entire data is received.

2: Serial.read()

This function is used to read the received data from the serial port. We will save received data in any variable for any condition to ascertain.The variable could also be integer or character.

3: Serial.write()

This function is same as Serial.print() and Serial.println() explained in How To Send Serial Data From Arduino To Laptop or PC. This function returns the data to the serial port of the arduino.

Circuit diagram: 

circuit diagram for serial communication
Circuit Diagram
Code:
code for receiving serial data from laptop
Code
Download:


Video:


If you have got any question concerning this article then be happy to comment below or contact us via social network like facebook 

How To Send Serial Data From Arduino To Laptop or PC

By // 6 comments:
Serial Communication plays important role within the communication system. All micro-controller should have serial communication port.Serial communication provides a text-user-interface(TUI). One will use serial port of microcontroller to send data serially to laptop/PC or receive data serially from laptop/PC.Here we use arduino board to communicate with the laptop. Arduino board have a minimum of one serial port to communicate known as UART and USART. It communicates with digital pin 0 and 1 of arduino refer to as RX and TX pin as well as with the computer via USB.

send data to pc with arduino
Virtual Terminal
Interfacing LCD With Arduino UNO

Arduino has a built-in function for serial port thus there is no need to go into register detail. In Arduino IDE, one can easily call the serial function for the serial port and job is finished. A simple connection for serial communication is shown below
 serial communication connection
Connection For Serial Communication
For serial communication with arduino, we have to use three function known as Serial.begin(), Serial.print(),Serial.println(). Their function is as follows

1: Serial.begin()
To initialize the serial port for the communication we use this function.In this function baud rate is used to initialize the serial port. Here we have used 9600 baud rate for the communication.

2: Serial.print()
This function helps to send serial data to the device connected to the serial port of arduino board. Using this function we are able to send both ASCII and string to the device.
3: Serial.println()
This function is used to print the send data into a new line and all the function is same as the previous function.
Circuit diagram:

circuit diagram for serial communication
Circuit Diagram
Code: 
Download the hex file from below.this image is just for showing. we connected a led to pin no 5 of arduino board therefore whenever data is sent to laptop/PC led can blink. 

code for serialcommunication
Code
Download:



Video: