Notice
Recent Posts
Recent Comments
Link
반응형
관리 메뉴

eng-life 님의 블로그

Arduino Uno Communication (2) 본문

ENGR

Arduino Uno Communication (2)

eng-life 2025. 6. 1. 11:37
반응형

Arduino uses serial communication to communicate with your laptop or desktop. 
Serial communication is a widely used protocol for transmitting (Tx) and receiving (Rx) binary data and requires a few easy functions to get it started with Arduino.

 

1. Upload code to Arduino

  If successfully uploaded, you will know that your PC/MAC can communicate with your Arduino.

Uploading codes

What is code?

Something you want the computer to do:

  • There are different programming languages in the same way that we have different languages
    We say “Hello,” Arduino says 
         Serial.begin(9600);
         Serial.print(“Hello”);
  • Arduino language is based on C/C++
  • Just like with spoken human languages, once you know one learning others is easier.

2. Modify the sketch to add the followig to the "void setup( )"

 

Serial.begin( )

  • Serial.begin( ) needs us to specify a communication rate (baud rate).
  • We use 9600 bits per second, so put 9600 in the parentheses.  
  • Serial.begin( ) is in setup because this rate needs to be set only once.

3. Modify your sketch to include the following:

  • Serial.print( ) will just print to the monitor.
  • Serial.println( ) will print to the monitor and then go to the next line (essentially pushes ‘return’)

4. Compile code and check for messages.

5. Upload code to Arduino (will check communication with Arduino too).

 

6. To open the serial monitor, click her

7. You should see this on your serial monitor.

 

8. Commenting

  • Arduino ignores comments but humans read them.
  • Words become light gray if they commented out.
  • Put // in front of a line to comment out whole line.
  • To comment out an entire section, put /* at the beginning and */ at the end.

Comments

 

'ENGR' 카테고리의 다른 글

Arduino Uno: Potentiometer (6)  (1) 2025.06.03
Arduino Uno: Analog vs. Digital (5)  (0) 2025.06.03
Arduino Uno: LED Visual Display (4)  (0) 2025.06.02
Arduino Uno: Blink an LED (3)  (3) 2025.06.02
Arduino Uno Overview (1)  (2) 2025.06.01