Difference Between Iterator and Enumeration Interface in Java

AmitDiwan
Updated on 24-Mar-2021 12:34:07

602 Views

In this post, we will understand the difference between iterator and enumeration interfaces in Java.IteratorIt is a universal cursor.It can be applied to all collection of classes.It contains the ‘remove’ method.It is not a legacy interface.It can be used to traverse over HashMap, LinkedList, ArrayList, HashSet, TreeMap, and TreeSet .It can perform modifications to perform operations on the collection while traversing through it.EnumerationIt is not a universal cursor.It is applied only to legacy classes.It doesn’t contain the ‘remove’ method.It is a legacy interface.This interface acts like a read-only interface.Hence, no modifications can be performed on a collection while traversing over ... Read More

Difference Between malloc and calloc

AmitDiwan
Updated on 24-Mar-2021 12:31:57

942 Views

In this post, we will understand the difference between malloc and calloc.MallocThe method ‘malloc’ is used to assign a block of memory when it is requested.It doesn’t clear the memory.It only initializes the allocated memory when explicitly requested.It allocates memory of a specific ‘size’.This size is passed as parameter to it.This size is allocated from a heap.It performs its job quickly.Examplevoid *malloc(size_t size);CallocIt assigns the requested memory to multiple blocks.This memory allocated is initiated to zero.This initialization to 0 is done by ‘calloc’ method.It allocates memory to the required operation of a specific ‘size’, i.e num * size.The ‘num’ refers ... Read More

Difference Between Stack and Queue

AmitDiwan
Updated on 24-Mar-2021 12:28:30

970 Views

In this post, we will understand the difference between Stack and Queue.StackThey are based on LIFO- Last In First Out.This means the element inserted at the end is the first element to get deleted.Insertion and deletion happen in a stack from one end only, i.e the top.Insert operation is known as ‘push’ operation.Delete operation is known as ‘pop’ operation.A pointer is used to access the list, it is known as ‘top’.The ‘top’ points to the last element of the list.It helps work with problems associated with recursion.Representation of Stack (LIFO)QueuesThey are based on FIFO- First In First Out.This means the ... Read More

RTOS Introduction with Arduino

Yash Sanghvi
Updated on 24-Mar-2021 05:46:29

1K+ Views

RTOS stands for Real Time Operating System. It is used to run multiple tasks concurrently, schedule them as required, and enable them to share resources. Now, while getting into the details of RTOS is out of the scope of this article, we will walk through an example that will give you a fair idea of RTOS. For now, you can just note that RTOS will help you perform multi-tasking within your Arduino, just like how the OS on your machine helps you run multiple tasks (like writing mails, listening to music, etc.) simultaneously.Now, since we are concerned with microcontrollers, we ... Read More

Timer Interrupts in Arduino

Yash Sanghvi
Updated on 24-Mar-2021 05:41:38

4K+ Views

As discussed in another article, Timers are basically counters. When they reach the end of the count, they overflow. We can use this event to generate an interrupt. Now, the traditional way of generating the interrupts in Arduino involve changing a lot of registers. Luckily, we have libraries for making our lives easy.We will use the TimerOne library for generating interrupts on Timer1. Similarly, there is the TimerThree library for generating interrupts on Timer3 (not applicable for Arduino Uno).Go to Tools -> Manage Libraries and search for TimerOne and TimerThree (optional) and click Install.Next, import the library in your code ... Read More

Timers in Arduino Uno

Yash Sanghvi
Updated on 24-Mar-2021 05:39:15

10K+ Views

As discussed earlier, Arduino Uno has 3 timers: Timer0, Timer1 and Timer2. Timer0 and Timer2 are 8-bit counters (they count from 0 to 255), while Timer1 is a 16-bit counter (it counts from 0 to 65535). Internally, Timer0 is used for the millis() function, and therefore, it is recommended not to mess with it. You can use Timer1 and Timer2 for your custom requirements.Note that the clock frequency of Arduino Uno is 16 MHz. Therefore, no timer can have intervals shorter than (1/16000000). However, for most applications, you would want longer intervals (lower frequencies). In other words, you would want ... Read More

Timers in Arduino

Yash Sanghvi
Updated on 24-Mar-2021 05:38:49

2K+ Views

Every microcontroller has one or more timers that help the users perform tasks at precise intervals. Arduino Uno, for example, has 3 timers: Timer0, Timer1 and Timer2. Other boards may have the same or different number of timers, which you can find from the datasheet of that board/ microcontroller. What are timers?Timers are essentially counters. Let me give you a simple example. Say you want to trigger a task every 5 seconds. Now, if you have a counter which can count from 0 to 255, then if you somehow adjust the rate of counting such that it finishes counting exactly in ... Read More

PWM in Arduino

Yash Sanghvi
Updated on 24-Mar-2021 05:37:46

2K+ Views

What is PWM?PWM refers to Pulse Width Modulation. In very simple terms, we can output a square wave from certain pins of the Arduino board, and we can control the fraction of time for which the wave will be at the HIGH state (known as the duty cycle).Why is PWM needed?PWM finds several applications. An important application is running motors. The RPM of the motor can be controlled by the PWM output. PWM can also be used in general for generating voltages between HIGH and LOW. So, if your HIGH level is at 5V and LOW level is at 0V, ... Read More

Difference Between Float and Double in Arduino

Yash Sanghvi
Updated on 24-Mar-2021 05:34:40

7K+ Views

FloatFloating point numbers are stored using 4 bytes (32 bits).Their max value can be 3.4028235E+38 and their min value can be -3.4028235E+38.They have a precision of about 6-7 decimal places.DoubleWhile on several platforms, double has more precision than float. However, on most Arduino boards (Uno and many other ATmega boards), double has the same size as float. Arduino Due is an exception, wherein double has a size of 8 bytes (compared to 4 bytes of float).On the boards where double is stored using 8 bytes, the max value can be 1.7*10^308 and the min value can be -1.7*10^308. On the ... Read More

Difference Between Signed and Unsigned Integer in Arduino

Yash Sanghvi
Updated on 24-Mar-2021 05:33:44

2K+ Views

When you define an integer, it is signed by default. In other words, it can accept both positive and negative values. Unsigned integers, as the name suggests, accept only positive values. Therefore, they have a higher range.If you are using a board that uses two bytes (16 bits) to represent an integer, then the maximum range you would get for an unsigned integer is 0 to 65535 (216-1).However, when representing signed integers, the range would be -32767 to +32767. Note that 32767 corresponds to (215 -1). As you can see, the most significant bit seems to be out of action. ... Read More

Advertisements