Yash Sanghvi has Published 201 Articles

How to show line numbers in Arduino IDE?

Yash Sanghvi

Yash Sanghvi

Updated on 29-May-2021 12:52:36

3K+ Views

Line numbers are often necessary when working with large files consisting of several functions. Most developers prefer to have the line numbers shown in their code editing software.By default, line numbers are hidden in the Arduino IDE. In order to display the line numbers, go to File → Preferences.In the ... Read More

Arrays in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 02-Apr-2021 09:02:33

5K+ Views

Declaring an ArrayIn order to declare an array, you follow the syntax give below −Syntaxtype array_name[array_size];Exampleschar buf[500]; int new_array[200];Accessing elements of the arrayThe array element numbering starts from 0. The element can be accessed by specifying the index of the element in square brackets against the name of the array. ... Read More

Timer Interrupts in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 24-Mar-2021 05:41:38

4K+ Views

As discussed in another article, Timers are basically counters. When they reach the end of the count, they overflow. We can use this event to generate an interrupt. Now, the traditional way of generating the interrupts in Arduino involve changing a lot of registers. Luckily, we have libraries for making ... Read More

Timers in Arduino Uno

Yash Sanghvi

Yash Sanghvi

Updated on 24-Mar-2021 05:39:15

10K+ Views

As discussed earlier, Arduino Uno has 3 timers: Timer0, Timer1 and Timer2. Timer0 and Timer2 are 8-bit counters (they count from 0 to 255), while Timer1 is a 16-bit counter (it counts from 0 to 65535). Internally, Timer0 is used for the millis() function, and therefore, it is recommended not ... Read More

Timers in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 24-Mar-2021 05:38:49

2K+ Views

Every microcontroller has one or more timers that help the users perform tasks at precise intervals. Arduino Uno, for example, has 3 timers: Timer0, Timer1 and Timer2. Other boards may have the same or different number of timers, which you can find from the datasheet of that board/ microcontroller. What are ... Read More

Difference between float and double in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 24-Mar-2021 05:34:40

7K+ Views

FloatFloating point numbers are stored using 4 bytes (32 bits).Their max value can be 3.4028235E+38 and their min value can be -3.4028235E+38.They have a precision of about 6-7 decimal places.DoubleWhile on several platforms, double has more precision than float. However, on most Arduino boards (Uno and many other ATmega boards), ... Read More

Difference between signed and unsigned integer in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 24-Mar-2021 05:33:44

2K+ Views

When you define an integer, it is signed by default. In other words, it can accept both positive and negative values. Unsigned integers, as the name suggests, accept only positive values. Therefore, they have a higher range.If you are using a board that uses two bytes (16 bits) to represent ... Read More

Defining new functions in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 24-Mar-2021 05:26:57

316 Views

Defining new functions in Arduino is equivalent to defining the functions in C.The syntax is −Syntaxreturn_type function_name(arg_type arg)The only difference is that in C, the function needs to be declared at the top, if it is invoked before its definition. No such constraint exists in Arduino. The following code demonstrates ... Read More

Convert string to lowercase or uppercase in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 24-Mar-2021 05:24:09

7K+ Views

In order to convert a string to lower/upper case, the in-built .toLowerCase() and .toUpperCase() functions can be used.Note: These functions change the original string itself, and don't return a new string with the changes.The implementation is shown below −Examplevoid setup() {    Serial.begin(9600);    Serial.println();    String s1 = "Hello World"; ... Read More

Replace characters in a string in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 24-Mar-2021 05:23:39

7K+ Views

The .replace() function in Arduino allows you to replace a character or a substring with another character/substring in Arduino.Note: This function replaces substrings in the original string itself, and does not return a new string containing the changes.Examples are given in the code below −Examplevoid setup() {    Serial.begin(9600);   ... Read More

Advertisements