Arduino Boards Articles

Page 4 of 10

Square and Square root in Arduino

Yash Sanghvi
Yash Sanghvi
Updated on 29-May-2021 4K+ 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 = x*x;However, Arduino does have a separate function for calculating squares. The syntax is −sq(x) where x is a number of any data type. This again returns a double.ExampleThe following example illustrates the use of these functions −void setup() {    // put your setup code here, to run once:   ...

Read More

Timer1 based PWM in Arduino Uno

Yash Sanghvi
Yash Sanghvi
Updated on 29-May-2021 9K+ 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 5 and 6, on which it is 980 Hz (about 1s time period). With analogWrite() you get control over the duty cycle, but not on the frequency of the generated square wave.In this article, we will look at another way of setting PWM in Arduino Uno, specific to Timer1. The advantage ...

Read More

Understanding Arduino Uno pinout

Yash Sanghvi
Yash Sanghvi
Updated on 29-May-2021 724 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 if you are using an external power source (and not the USB) to power the board. The recommended voltage range is 7-12 V.The 3.3V and 5V pins provide 3.3V and 5V outputs respectively, and should be used to power other components using the Arduino board. The maximum current from the ...

Read More

Store a new file in SD Card connected to Arduino

Yash Sanghvi
Yash Sanghvi
Updated on 29-May-2021 802 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 as input. If it takes in 3.3V, connect it to the 3.3V pin on Arduino Uno.Code WalkthroughWe will be walking through the example code that comes in with the inbuilt SD library. You can access it from File → Examples → SD → DataloggerAlternatively, you can access the code on ...

Read More

List files stored in SD Card connected to Arduino

Yash Sanghvi
Yash Sanghvi
Updated on 29-May-2021 5K+ Views

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 Card Holder takes 5V as input. If it takes in 3.3V, connect it to the 3.3V pin on Arduino Uno.Code WalkthroughWe will be walking through the example code that comes in with the inbuilt SD library. You can access it from File → Examples → SD → listfilesAlternatively, the code ...

Read More

Read a file from SD Card connected to Arduino

Yash Sanghvi
Yash Sanghvi
Updated on 29-May-2021 2K+ Views

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 takes 5V as input. If it takes in 3.3V, connect it to the 3.3V pin on Arduino Uno.Code WalkthroughWe will be walking through the example code that comes in with the inbuilt SD library. You can access it from File → Examples → SD → ReadWriteAlternatively, you can find the ...

Read More

Append to an existing file stored in SD Card connected to Arduino

Yash Sanghvi
Yash Sanghvi
Updated on 29-May-2021 3K+ Views

In this tutorial, we will, as the title suggests, see how to append to a file in and SD Card connected to Arduino. Actually, it is quite simple. If you have gone through any previous articles on SD Card, then you only need to know thatmyFile = SD.open("example.txt", FILE_WRITE);opens example.txt in the append mode only. Thereafter, myFile.println(dataString);appends to the existing file, and doesn’t overwrite the existing content.If you haven’t gone through any other articles on SD Card, I’d suggest reading the "Store a new file in SD Card connected to Arduino" article. That is a detailed article containing the circuit ...

Read More

Connect SD Card with Arduino and get Card Info

Yash Sanghvi
Yash Sanghvi
Updated on 29-May-2021 534 Views

In this tutorial, we will connect our Arduino Uno to an SD Card and extract the card info.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 as input. If it takes in 3.3V, connect it to the 3.3V pin on Arduino Uno.Code WalkthroughWe will be walking through the example code that comes in with the inbuilt SD library. You can access it from File → Examples → SD → CardInfoWe begin with the inclusion of ...

Read More

Wait for user input to start a sketch in Arduino

Yash Sanghvi
Yash Sanghvi
Updated on 29-May-2021 1K+ Views

A problem faced by several people using Arduino, or any microcontroller board for that matter, is that you may forget to start the Serial Monitor before programming the board, and miss some print statements by the time you open the Serial Monitor.One way to overcome this is to start the sketch only after an input is received from the user, via the Serial Monitor. This will ensure that you don’t miss any prints on the Serial Monitor because of the delay in starting the Serial Monitor.Examplevoid setup() {    // put your setup code here, to run once:    Serial.begin(9600); ...

Read More

Reserve memory in Arduino for string manipulation

Yash Sanghvi
Yash Sanghvi
Updated on 29-May-2021 967 Views

It may happen that a string may change length dynamically during the execution of a program.If you want to ensure that there is always enough memory available for your string, you can reserve some memory using the reserve() function.SyntaxString1.reserve(n_bytes);Where String1 is the string for which you are reserving memory, and n_bytes (unsigned int) is the number of bytes to be reserved in the memory.ExampleString s1 = "Hello"; void setup() {    // put your setup code here, to run once:    Serial.begin(9600);    Serial.println();    s1.reserve(20);    s1 = s1+" World!";    Serial.println(s1);    s1 = s1+" I'm now trying ...

Read More
Showing 31–40 of 99 articles
« Prev 1 2 3 4 5 6 10 Next »
Advertisements