Getting Data from Vibration Sensor Using Arduino

Yash Sanghvi
Updated on 31-May-2021 14:49:41

3K+ Views

In this tutorial, we will interface Arduino with the MPU6050 Vibration sensor.Circuit DiagramAs you can see, we connect Vcc to 3.3V, GND to GND, SDA to A4 and SCL to A5. A4 and A5 also serve as SDA and SCL on Arduino Uno.Code WalkthroughThe code is given below −#include const int MPU_ADDR = 0x68; // I2C address of the MPU-6050 int16_t AcX, AcY, AcZ, Tmp, GyX, GyY, GyZ; void setup() {    Serial.begin(9600);    Wire.begin();    Wire.beginTransmission(MPU_ADDR);    Wire.write(0x6B); // PWR_MGMT_1 register    Wire.write(0); // set to zero (wakes up the MPU-6050)    Wire.endTransmission(true);    Serial.println("Setup complete"); } ... Read More

Display Data on OLED Screen Using Arduino

Yash Sanghvi
Updated on 31-May-2021 14:49:17

886 Views

In this tutorial, we will interface Arduino with the SSD 1306 OLED Display.Circuit DiagramAs you can see, we connect Vcc to 3.3V, GND to GND, SDA to A4 and SCL to A5. A4 and A5 also serve as SDA and SCL on Arduino Uno.Required LibrariesThe following libraries will be required for interfacing Arduino Uno with the OLED Display −Adafruit SSD1306Adafruit GFXAdafruit BusIO (required by Adafruit GFX)Go to Tools → Manage Libraries, search for these libraries and click Install.ExampleThe code is given below −#include #include #include #define WIDTH 128 // OLED width (pixels) #define HEIGHT 64 // ... Read More

Interfacing GNSS Receiver with Arduino to Get Speed

Yash Sanghvi
Updated on 31-May-2021 14:45:34

252 Views

In this tutorial, we will interface Arduino with a GNSS Receiver and obtain the speed. If possible, you can run this code in a moving vehicle, because otherwise you will get 0 speed if your GNSS receiver is stationary. Any GNSS receiver generally uses UART for communication. We will be using the ublox Neo-6M GNSS module for thisCircuit DiagramAs you can see, we connect Vcc to 5V, GND to GND, RX of the Neo 6M to pin 3 of Arduino Uno, and TX of Neo 6M to pin 4 of Arduino Uno.Required LibrariesTinyGPS library will be required for interfacing Arduino ... Read More

Map a 10-Bit Number to 8-Bit in Arduino

Yash Sanghvi
Updated on 31-May-2021 14:45:03

1K+ Views

Mappings often have to be performed in Arduino for a variety of reasons. One example would be mapping the 10-bit ADC output to 8-bit to save on storage. A 10-bit number would occupy 2-bytes for storage, whereas an 8-bit number would occupy just one byte and still preserve most of the information of the 10-bit number.Arduino has a readymade map() function for achieving this.Syntaxmap(value, fromLow, fromHigh, toLow, toHigh)where, value is the value to be mapped; fromLow and fromHigh are the bounds of the range of the current value; toHigh and toLow are the bounds of the range of the new ... Read More

Check If a Character Is Printable in Arduino

Yash Sanghvi
Updated on 31-May-2021 14:43:23

644 Views

Through various operations, you may come across characters which are not printable. After all, a char is an 8-bit number, and if you look at the ASCII table only the values from 32 to 127, or a total of 96 values out of 127 are printable (see http://facweb.cs.depaul.edu/sjost/it212/documents/ascii-pr.htm). ASCII uses only 7 digits, instead of 8.Thus, if you get a char output from a function, and wish to check if it is printable, then you can use the isPrintable() function of Arduino.SyntaxisPrintable(myChar)where myChar is the character being checked. This function returns a true if the character is printable.Examplevoid setup() {   ... Read More

Enable and Disable Interrupts in Arduino

Yash Sanghvi
Updated on 31-May-2021 14:42:53

7K+ Views

If you wish to disable interrupts (when executing some critical piece of code, especially one which should be completed within a given time period), you can do that with the help of the noInterrupts() function.Once your critical code has executed and you wish to re-enable the interrupts, you can do that using interrupts() function. Note that interrupts are enabled by default in Arduino, and therefore, calling interrupts() without an initial call to noInterrupts() is unnecessary.ExampleThe general structure of a code containing noInterrupts() and interrupts() is given below −void setup() {    // put your setup code here, to run once: } ... Read More

Detach Interrupts from a Source in Arduino

Yash Sanghvi
Updated on 31-May-2021 14:42:30

1K+ Views

We have seen that in order to attach interrupts to a source, we use the .attachInterrupt() function, with the required arguments.For example, for attaching the interrupts to a specific pin, we useattachInterrupt(digitalPinToInterrupt(pin), ISR, mode);In the same way, to detach the interrupt from a source, we can call the detachInterrupt() function. This will simply disable that particular interrupt. The recommended syntax for disabling pin interrupts is −detachInterrupt(digitalPinToInterrupt(pin))where pin is the pin number on which you wish to disable the interrupt.

Interfacing GNSS Receiver with Arduino to Get Location

Yash Sanghvi
Updated on 31-May-2021 14:41:56

1K+ Views

In this tutorial, we will interface Arduino with a GNSS Receiver and obtain the current location. Any GNSS receiver generally uses UART for communication. We will be using the ublox Neo6M GNSS module for thisCircuit DiagramAs you can see, we connect Vcc to 5V, GND to GND, RX of the Neo 6M to pin 3 of Arduino Uno, and TX of Neo 6M to pin 4 of Arduino Uno.Required LibrariesTinyGPS library will be required for interfacing Arduino Uno with the OLED Display −Go to Tools → Manage Libraries, search for this library, and click Install.Code WalkthroughWe will walkthrough an example ... Read More

Controlling a DC Motor with Arduino

Yash Sanghvi
Updated on 31-May-2021 14:41:28

661 Views

A DC Motor is the simplest kind of motor. It has two terminals or leads. When connected with a battery the motor will rotate, and if the connections are reversed, the motor will rotate in the opposite direction. If the voltage across the terminals is reduced, the motor speed will reduce accordingly.In this article, we will see how to interface a DC Motor with Arduino and control its speed. We won’t be looking at reversing the direction of the motor, as that will require an additional IC (an H-bridge). At the end of this article, I’ll provide links to some ... Read More

Controlling a Stepper Motor with Arduino

Yash Sanghvi
Updated on 31-May-2021 14:39:12

846 Views

A stepper motor divides the full rotation into a number of discrete steps, ranging from as low as 12 to as high as 200 steps per revolution (corresponding to angles of 30 degrees per step to 1.8 degrees per step). While a DC motor rotates continuously, a stepper motor rotates discretely, in step angles.Circuit DiagramThe circuit diagram and the required components for both Unipolar and Bipolar stepper motors can be found here − https://www.arduino.cc/en/Tutorial/LibraryExamples/StepperOneRevolutionNote that the stepper motor is connected to pins 8-11 of Arduino Uno, via a Darlington Array (for unipolar stepper) or H-bridge (for bipolar stepper). The stepper ... Read More

Advertisements