Yash Sanghvi has Published 220 Answers

Stop Autoscroll in Serial Terminal in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 23-Mar-2021 11:30:33

Suppose you have a code like the one below −Examplevoid setup() {    Serial.begin(9600); } void loop() {    // put your main code here, to run repeatedly:    Serial.println(analogRead(A0)); }As you can see, it is continuously printing the results of ADC conversion on A0 pin. Such programs can fill ... Read More

Print new line and tab in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 23-Mar-2021 11:29:44

In order to print a newline, you can either introduce the '\n' character in your text, or use Serial.println() instead of Serial.print()An example code is given below −Examplevoid setup() {    // put your setup code here, to run once:    Serial.begin(9600);    Serial.println();    Serial.print("This is line1\nThis is line2\n"); ... Read More

Reduce decimals while printing in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 23-Mar-2021 11:26:19

Often some functions can output really long floating-point numbers, with several decimal digits. Several times, we are just interested in the first couple of decimal digits, and the remaining digits just reduce the readability and make the Serial Monitor window cluttered.In order to round of floating-point numbers when printing to ... Read More

Print binary values in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 23-Mar-2021 11:25:48

In order to print binary representation of numbers/ characters in Arduino, you can add 'BIN' as the second argument of your Serial.print() function. Example is shown below −Examplevoid setup() {    // put your setup code here, to run once:    Serial.begin(9600);    Serial.println();    Serial.println(75);    Serial.println(75, BIN);   ... Read More

Print hexadecimal values in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 23-Mar-2021 11:21:41

In order to print hexadecimal equivalents of numbers or characters, adding 'HEX' as the second argument of Serial.print() will be sufficient.The following code demonstrates this −Examplevoid setup() {    // put your setup code here, to run once:    Serial.begin(9600);    Serial.println();    Serial.println(75);    Serial.println(75, HEX);    Serial.println('A');   ... Read More

Print plain text in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 23-Mar-2021 11:21:18

To print plain text on the Serial Monitor, the Serial.print() function can be used.In order to use this function, Serial needs to be initialized first (in the setup preferably). A typical implementation is shown below −Examplevoid setup() {    // put your setup code here, to run once:    Serial.begin(9600); ... Read More

Add delay in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 23-Mar-2021 11:20:56

In order to add time delays in Arduino, you can use the delay() function. It takes as an argument the value of the delay in milliseconds. An example execution is given below −Examplevoid setup() {    // put your setup code here, to run once:    Serial.begin(9600); } void loop() ... Read More

How to change programmer in Arduino IDE

Yash Sanghvi

Yash Sanghvi

Updated on 23-Mar-2021 11:18:59

If you wish to program your board using the USB Cable, then you don't need to make any changes in the default settings. Read further only if you have an external programmer. If you do wish to program the board using an external programmer, you can select the programmer of ... Read More

Change board selection in Arduino IDE

Yash Sanghvi

Yash Sanghvi

Updated on 23-Mar-2021 11:17:34

Changing the board is quite straightforward in Arduino IDE. You need to go to Tools -> Board.The list of available boards opens up. You can select the board of your choice. Once selected, you can verify that the Board name has changed in Tools -> Board.Please note that each board ... Read More

How to export the binary file of a code in Arduino IDE

Yash Sanghvi

Yash Sanghvi

Updated on 23-Mar-2021 11:14:59

Sometimes, you need to export the compiled binary of your code for sharing with colleagues, or for programming your board using some other programmers like ISP programmer, or for OTA (Over-The-Air update) purposes. This exported binary (actually hex file for Arduino boards) will contain not only your application code, but ... Read More

Advertisements