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 case insensitive comparison of two strings is to convert both the strings to lower case and then compare. However, Arduino has a function to compare two strings while ignoring case. As you’d have guessed, the function is equalsIgnoreCase.ExampleAn example implementation is given below −void setup() { // put your ... Read More
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 semaphore is a synchronization mechanism between tasks. More specifically, it is a signalling mechanism. A task in the waiting state may receive a semaphore which tells it to do some work. Once the task has done that work, it will give the semaphore back. In practice, this is maintained by ... Read More
By default, on a Windows machine, Arduino saves all the sketches in C:\Users\\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 space.In order to change the default location, go to File → Preferences.In the dialog box that opens up, the first input field is the Sketchbook location. Click on the ‘Browse’ button next to it and choose your desired path.After changing the path, click OK. Now, if you try to save a new ... Read More
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(). The syntax is −Syntaxvoid vTaskResume( TaskHandle_t xTaskToResume );This again takes the handle of the task to be resumed, and returns nothing.In order to see an example, we will walk-through the code given in −https://exploreembedded.com/wiki/Task_Suspend_and_ResumeAs you can see, four Task handles are declared initially, and the tasks are created in the ... Read More
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 to a value you are comfortable with.Click OK and the changes will reflect on your IDE immediately.
Suppose we have an array called nums and another value k. We have to find the number of non-empty subsequences of nums such that the sum of the minimum and maximum element on it is smaller or equal to k. The answers may be very large so return answer mod 10^9 + 7.So, if the input is like nums = [4,6,7,8] k = 11, then the output will be 4 because there are subsequences like[4], here minimum is 4, maximum is 4, so 4+4
Suppose we have m x n binary matrix, we have to find how many square submatrices have all ones.So, if the input is like.011111110111then the output will be 15, as there are 10 squares of side 1. 4 squares of side 2 and 1 square of side 3. Then total number of squares = 10 + 4 + 1 = 15.To solve this, we will follow these steps −if matrix has single one, thenreturn 1rows := row count of matrixcols := column count of matrix[0]result := 0for row in range 0 to rows - 1, dofor col in range 0 ... Read More
Suppose we have m x n binary matrix, we have to find how many submatrices have all ones.So, if the input is like101011011then the output will be 13 as there are 6 (1x1) matrices, 3 (2, 1) matrices, 2 (1x2) matrices, 1 (3x1) matrix and 1 (4x4) matrix.To solve this, we will follow these steps −m := row count of matrixn := column count of matrixdp := a zero matrix of same size m x nfor i in range 0 to m - 1, dofor j in range 0 to n - 1, doif i is same as 0 and ... Read More
Suppose we have an array nums with n positive elements. If we compute the sum of all non-empty contiguous subarrays of nums and then sort them in non-decreasing fashion, by creating a new array of n*(n+1)/2 numbers. We have to find the sum of the numbers from index left to index right (1-indexed), inclusive, in the new array. The answer may be very large so return result modulo 10^9 + 7.So, if the input is like nums = [1, 5, 2, 6] left = 1 right = 5, then the output will be 20 because here all subarray sums are ... Read More
Suppose we have an array called nums. We can change one element from this array to any value in one move. We have to find the minimum difference between the largest and smallest value of nums after preforming at most 3 moves.So, if the input is like nums = [3,7,2,12,16], then the output will be 1 because we can make given array to [1,1,0,1,1], so the maximum is 1 and minimum is 0, so the difference is 1.To solve this, we will follow these steps −if size of nums
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP