Yash Sanghvi has Published 220 Answers

Do-while loop in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 29-May-2021 14:03:29

The do-while loop’s syntax in Arduino is similar to the syntax in C. It is given below −do{    //Code } while (condition);Note the semicolon at the end.Examplevoid setup() {    // put your setup code here, to run once:    Serial.begin(9600);    Serial.println();    int i = 5;   ... Read More

Timer registers in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 29-May-2021 14:03:08

In a previous article, we used the TimerOne library to add timer interrupts to Arduino. But what if we wish to generate timer interrupts without a third-party library? In that case, you will directly have to meddle with the timer registers in Arduino. In this article, we will just introduce ... Read More

Square and Square root in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 29-May-2021 14:02:50

Arduino has support for several popular math functions, square and square root being among them. Let’s look at the square root first.Syntaxsqrt(x)where x is a number of any data type. It returns a double.For square, you ideally shouldn’t need a separate function. You can just multiply the number by itself.x_squared = ... Read More

Trigonometric expressions in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 29-May-2021 14:02:29

Arduino provides 3 basic trigonometric functions: sin(), cos() and tan(). All other trigonometric expressions can be derived from these three functions.All the three functions take in angle in radians (type float) as the input. They return a double.For sin() and cos(), the value is between -1 and 1. The value ... Read More

Generate random numbers in Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 29-May-2021 14:02:08

Generating random numbers is one of the key requirements from microcontrollers. Random numbers have several applications. Let’s not get there. You must have an application in mind, which brought you to this page. Generating random numbers is very easy in Arduino, thanks to the inbuilt random() function.Syntaxrandom(min, max)ORrandom(max)where min is ... Read More

Timer1 based PWM in Arduino Uno

Yash Sanghvi

Yash Sanghvi

Updated on 29-May-2021 14:01:47

In an earlier article, we have seen how PWM can be set on Arduino Uno using the analogWrite() function. Pins 3, 5, 6, 9, 10 and 11 of Arduino Uno can support PWM. The frequency of the square wave is 490 Hz (about 2 ms time period) on all pins except ... Read More

Understanding Arduino Uno pinout

Yash Sanghvi

Yash Sanghvi

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

The Arduino Uno board looks like the following −As you can see, the pins are broadly divided into 3 sections. Two sections at the bottom of the image, and one at the top.Let us look at the bottom sections.Section 1The first section contains power pins.The Vin pin can be used ... Read More

Store a new file in SD Card connected to Arduino

Yash Sanghvi

Yash Sanghvi

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

In this tutorial, we will create a new file in an SD Card connected to Arduino Uno.Circuit DiagramThe circuit diagram is shown below −As you can see, you need to make the following connections −SD Card HolderArduino UnoVcc5VGNDGNDMISO12MOSI11SCK13CS10Only for the Vcc, make sure that your SD Card Holder takes 5V ... Read More

List files stored in SD Card connected to Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 29-May-2021 13:50:45

As the title suggests, in this tutorial, we will be listing the files stored in an SD Card connected to Arduino.Circuit DiagramThe circuit diagram is shown below −As you can see, you need to make the following connections −SD Card HolderArduino UnoVcc5VGNDGNDMISO12MOSI11SCK13CS10Only for the Vcc, make sure that your SD ... Read More

Read a file from SD Card connected to Arduino

Yash Sanghvi

Yash Sanghvi

Updated on 29-May-2021 13:50:20

As the title suggests, in this tutorial, we will read a file from an SD Card connected to Arduino.Circuit DiagramThe circuit diagram is shown below −As you can see, you need to make the following connections −SD Card HolderArduino UnoVcc5VGNDGNDMISO12MOSI11SCK13CS10Only for the Vcc, make sure that your SD Card Holder ... Read More

Advertisements