Yash Sanghvi has Published 220 Articles

Basic analogRead in Arduino Program

Yash Sanghvi

Yash Sanghvi

Updated on 29-May-2021 14:27:05

589 Views

Converting analog values to digital is a common requirement from microcontrollers in general, and Arduino is no different. Arduino IDE has a built-in analogRead function to facilitate the conversion of analog values to digital.From the programming perspective, the only thing you require to know is the pins of your microcontroller that ... Read More

Bitwise AND and OR in Arduino

Yash Sanghvi

Yash Sanghvi

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

1K+ Views

Bitwise AND/ OR means AND/ OR performed at a bit-level, individually. Each number has its binary representation. When you perform the bitwise AND of one number with another, the AND operation is performed on the corresponding bits of the two numbers. Thus, LSB of number 1 is ANDed with the ... Read More

Do-while loop in Arduino

Yash Sanghvi

Yash Sanghvi

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

1K+ Views

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

4K+ Views

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

3K+ Views

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

2K+ Views

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

1K+ Views

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

7K+ Views

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

316 Views

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

579 Views

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

Advertisements