Yash Sanghvi has Published 220 Answers

Digital Read in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 29-May-2021 13:29:22

Just like analogRead() helps you to read analog voltages, digitalRead() helps you read digital levels.SyntaxdigitalRead(pin)When pin is the number of the pin whose digital level you wish to read. This function returns either HIGH or LOW.Please note that if the pin you are wishing to read is not connected to ... Read More

Get the last occurrence of a substring within a string in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 29-May-2021 13:28:49

Just like indexOf() helps identify the first occurrence of a substring within a string, the lastIndexOf() function helps identify the last occurrence. This is because lastIndexOf() performs backward search, while indexOf() performs forward search.syntaxmyString.lastIndexOf(substr)Where substr is the substring to search for in myString. It can be a character or a string.Just like indexOf(), this ... Read More

Get the first occurrence of a substring within a string in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 29-May-2021 13:27:49

The indexOf() function within Arduino scans a string from the beginning, and returns the first index of the specified substring within the string. The syntax is −SyntaxmyString.indexOf(substr)where substr is the substring to search for. It can be of type character or string.Optionally, you can provide a different starting point to begin the search ... Read More

How to Trim a String in Arduino?

Yash Sanghvi

Yash Sanghvi

Updated on 29-May-2021 13:11:42

Sometimes, a string can contain leading or trailing whitespaces. Arduino has a trim() function that removes all these leading/trailing whitespaces from the string.SyntaxString1.trim()Where String1 is the string that you need to trim. Please note that this function doesn’t return anything. String1 itself is modified.ExampleThe following example illustrates this −void setup() ... Read More

Check if two strings are equal while ignoring case in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 29-May-2021 13:11:04

We know that String1.equals(String2) can be used to find out if String1 and String2 are equal in Arduino. However, this function is case sensitive. So, if there is a difference in the case of even a single character, this function will return false. A strategy that people use to perform ... Read More

Semaphore and Mutex in FreeRTOS using Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 29-May-2021 13:09:18

Semaphore and Mutex are tools/mechanisms to bring about synchronization between tasks in FreeRTOS. Often, two tasks need to share a resource, or one task needs to tell another that it is idle/waiting. Semaphores and Mutex help here. In this article, we will look at the concepts of semaphore and mutex.SemaphoreA ... Read More

Change the default location for saving sketches in Arduino IDE

Yash Sanghvi

Yash Sanghvi

Updated on 29-May-2021 13:08:43

By default, on a Windows machine, Arduino saves all the sketches in C:\Users\<Your User Name>\Documents\Arduino. Now, for whatever reason, you may want to change this default location. A common reason is that the C: has limited storage and you’d like to save sketches to a drive which has enough free ... Read More

Suspend/Resume tasks in FreeRTOS using Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 29-May-2021 13:04:26

If you wish to suspend a task in FreeRTOS, there is a function vTaskSuspend() that can be used. The syntax is −Syntaxvoid vTaskSuspend( TaskHandle_t xTaskToSuspend );As you can see, it takes the handle of the task to suspend as the argument and returns nothing. A suspended task can be resumed using vTaskResume(). ... Read More

How to increase the font size of text in Arduino IDE?

Yash Sanghvi

Yash Sanghvi

Updated on 29-May-2021 13:03:31

The default font size of Arduino IDE can be a bit too small for some developers. In order to increase the font size, go to File → Preferences.In the dialog box that opens up, change the value of Editor Font size. The default value is 12. You can set it ... Read More

Structs in Arduino program

Yash Sanghvi

Yash Sanghvi

Updated on 29-May-2021 13:02:04

A struct is simply a collection of different types of variable. Structs in Arduino mimic the structs in C language. So, if you are familiar with C structs, Arduino structs shouldn’t be an issue. The struct declaration syntax is as follows −Syntaxstruct structName{    item1_type item1_name;    item2_type item2_name;    . ... Read More

Advertisements