Category:PCB Arduino

Group Administrators: 1 | Group Member: 84 | Group Threads: 59

Arduino is an open-source electronics platform based on easy-to-use hardware and software. It's intended for anyone making interactive projects. About Arduino and Arduino Projects sharing are appreciated.

Thread Reply
Communicate serially with the Arduino is really easy Reply 2017-01-22 19:19:19
2K+ views
1 comments
279 likes

nestandart

Leave A Message

Follow

Communicating serially with the Arduino is really easy. Here, we'll show how to take some temperature measurements and then send the measurements over the serial link.
Unlike other devices, Arduino serial communications is simple to use. The Arduino programming environment has a feature, called the serial monitor, which is specifically for viewing the serial data communication. To activate it:
  1. Go to toolbar
  • Click on Serial monitor option
  • Select the baud rate specified the Serial.begin() function.
  • Here are some Arduino serial communications functions.
    Serial.begin(speed)
    This function sets the serial communications speed. It has one parameter, speed, which is usually set to 9600.
    Serial.read()
    This function receives data from the serial port.
    Serial.write(val)
    This function sends data via the serial port. The parameter val can be a single variable, a string or an array.
    Serial.printIn(val, format)
    This functions prints val to the Arduino IDE serial monitor using some specific format.
    Making temperature measurements with an LM35
    The LM35 is an ideal temperature sensor for measuring ambient temperature. Different versions of the device are shown below.
    Connection Diagram
    The LM35 provides a linear output proportional to the temperature, with 0 V corresponding to 0 degrees C and an output voltage change of 10 mV for each degree C change. LM35s are easier to use than thermistors and thermocouples because they are so linear and require no signal conditioning.
    The output of an LM35 can be connected directly to a Arduino analog input. Because the Arduino analog-to-digital converter (ADC) has a resolution of 1024 bits, and the reference voltage is 5 V, the equation used to calculate the temperature from the ADC value is:
    temp = ((5.0 * analogRead(pin)) / 1024) * 100.0
    Experiment:
    Hardware Required
    • 1 x LM35 temperature sensor
    • 4 x LEDs
    • 2 X 220 Ohm resistors
    • 1 x Arduino Mega2560
    • 1 x breadboard
    • 10 x jumper wires
    Circuit Diagram
    Connect the components as shown in the circuit diagram above:
    The sensor will be powered by the 5V and GND pins from the Arduino. The sensor output connects to Arduino pin A0, and when the code reads the value of this analog voltage using the function analogRead(0), it returns a value from 0 to 1023. The program will then calculate the temperature using the formula:
    temp = ((5.0 * analogRead(pin)) / 1024) * 100.0
    or
    temp = analogRead(pin) * 0.48828125;
    Finally, the temperature reading will be written to the IDE serial monitor with the function Serial.print(). 

    279 likes
    Statement: This post is only the personal view of the author and does not represent the opinions of ALLPCB.com.

    Toni

    Leave A Message

    Follow

    You are a genuis!
    ThreadReply