Posts

Showing posts with the label fundamental

Hello World on Arduino Due, with message printed in Serial port

Image
There are no display on Arduino board (Arduino Due in my case). We can display message on Arduino IDE's Tools of Serial Monitor, by print on Serial. Hello World on Arduino Due, with message printed in Serial port. void setup() { //Setup Serial Port with baud rate of 115200 Serial.begin(115200); print("Hello World!"); } void loop() { } void print(String s){ Serial.print(s); }

Arduino Due code example: Serial communication - Rx

Image
Simple example run on Arduino Due to read data from Serial, then send back to Serial. void setup() { //Setup Serial Port with baud rate of 115200 Serial.begin(115200); } void loop() { if(Serial.available() > 0){ Serial.println((char)(Serial.read())); } }

Arduino Due code example: Serial communication - Tx

Image
Simple example run on Arduino Due to send data via Serial, with baud rate of 115200. #define MSG_SIZE 17 char hellomsg[MSG_SIZE] = {'H', 'e', 'l', 'l', 'o', ' ', 'A', 'r', 'd', 'u', 'i', 'n', 'o', '-', 'e', 'r', '!'}; void setup() { //Setup Serial Port with baud rate of 115200 Serial.begin(115200); } void loop() { for(int i = 0; i < MSG_SIZE; i++){ Serial.print(hellomsg[i]); delay[500]; } Serial.println(); delay(1000); }

An Introduction to the Arduino

Image