Friday, 18 November 2016

Pattern Question in HAPP Campus Drive

/*
1
1 2
2 3 3
3 4 4 4
*/

#include<stdio.h>
int main() {
 int i,j;
 for(i=1; i<=4; i++) {
  if((i-1) == 0) {
   printf("%d",i);
  }
  else {
   printf("%d",i-1);
  }
  for(j=1; j<i; j++) {
   printf("%d",i);
  }
  printf("\n");
 }
 return 0;
}

Thursday, 10 November 2016

Arduino - Installation

Installation of Arduino was never been difficult or confusing, here we will be learning how to install and set up the Arduino IDE. Once we install and set up Arduino IDE, we will be ready to upload our program on the Arduino board.

In this we will learn in easy steps how to set up the Arduino IDE on your computer and prepare your Arduino board to flush the code via USB cable.
Before we start installation process, we need some components or things required for the installation process. So the requirement are as follows,

1.       Arduino Board: Here, we will be using the Arduino UNO R3 Board. You can use different Arduino board like Mega, Leonardo, Lilypad, Nano or any other board as you like.


2.       USB Cable: Here, we will be using the Type-A to Type-B 2.0 USB Cable which is compatible with Arduino UNO R3. But you can use different USB Cable which is compatible with your Arduino Board.


3.       Arduino IDE: We will use this software to code for Arduino and upload it in the board.


4.       Computer: We need a computer system for programming the code for the Arduino.


This is all what we need for installing Arduino in our system. Now let’s start the process for installing the Arduino in our system.

1.       Step – 1: Download Arduino IDE Software
You can get different versions of Arduino IDE from the Download page on the Arduino Official website. You must select your software, which is compatible with your operating system (Windows, IOS, or Linux). 





2.       Step – 2: Power Up Your Board
The Arduino Uno automatically draw power from either, the USB connection to the computer or an external power supply.
Connect the Arduino board to your computer using the USB cable. The green power LED (labeled PWR/ON) should glow.





3.       Step – 3: Launch Arduino IDE
After your Arduino IDE software is downloaded, you need to unzip the folder. Inside the folder, you can find the application icon with an infinity label (application.exe). Double-click the icon to start the IDE.






4.       Step – 4: Open New Project
You can create new project by 2 ways:

a.       You can select New in File and then you can open your new Project.

b.      You can click/press CTRL+N and then you can open your new project.




5.       Step – 5: Open Existing Project
To open an existing project example, select:
File → Example → Basics → Blink.



6.       Step – 6: Select Your Arduino Board
Go to Tools → Board and select your board.




7.       Step – 7: Select Your Serial Port
Go to 
Tools → Serial Port menu. This is likely to be COM3 or higher (COM1 and COM2 are usually reserved for hardware serial ports).




8.       Step – 8: Upload the Program to Your Board
Simply click the "Upload" button in the environment. Wait a few seconds; you will see the RX and TX LEDs on the board, flashing. If the upload is successful, the message "Done uploading" will appear in the status bar.



For More Such Interesting Videos Please Visit our YouTube Channel Silly Tech TV

Arduino - Pinout


Before getting started with the Arduino, we should know different components which are present on Arduino Board and their functionalities or uses.

Here we will be using Arduino UNO R3 Board because it is the most popular Arduino Board among the users and in Arduino Board Family. And this is the best board to get started with Arduino, electronics and coding. Some of the Arduino Boards look differently from one another but most of them have common components present.



Basically, we need to know about 17 components which are present on Arduino Board, and those are as follows,

1.       USB (Power Supply): (1) Arduino board can be powered by using the USB cable from your computer. All we need to do is just connect the USB cable to the USB connection of Arduino Board and Computer system. The Arduino Board will automatically draw power from the computer system.
2.       Barrel Jack (Power Supply): (2) Arduino boards can be powered directly from the AC mains power supply by connecting it to the Barrel Jack using some AC Adapter or Battery as well.
3.       Voltage Regulator: (3)
The function of the voltage regulator is to control the voltage given to the Arduino board and stabilize the DC voltages used by the processor and other elements. This helps in damage reduction.
4.       Crystal Oscillator: (4)
The crystal oscillator helps Arduino in dealing with time issues. How does Arduino calculate time? The answer is, by using the crystal oscillator. The number printed on top of the Arduino crystal is 16.000H9H. It tells us that the frequency is 16,000,000 Hertz or 16 MHz.
5.       RESET (Restart/Reset Arduino): (5,17)
You can reset your Arduino board, i.e., start your program from the beginning. You can reset the UNO board in two ways. First, by using the reset button (17) on the board. Second, you can connect an external reset button to the Arduino pin labelled RESET (5).
6.       Pins (3.3, 5, GND, Vin): (6,7,8,9)
a.      3.3V (6) − Supply 3.3 output volt
b.      5V (7) − Supply 5 output volt
c.      GND (8)(Ground) − There are several GND pins on the Arduino, any of which can be used to ground your circuit.
d.      Vin (9) − This pin also can be used to power the Arduino board from an external power source, like AC mains power supply.
7.       Analog Pins: (10) The Arduino UNO board has six analog input pins A0 through A5. These pins can read the signal from an analog sensor like the humidity sensor or temperature sensor and convert it into a digital value that can be read by the microprocessor. It helps in reading discrete value of sensors.
8.       Microcontroller (Main): (11)  Each Arduino board has its own microcontroller (11). You can assume it as the brain of your board. The main IC (integrated circuit) on the Arduino is slightly different from board to board. The microcontrollers are usually of the ATMEL Company. You must know what IC your board has before loading up a new program from the Arduino IDE. This information is available on the top of the IC. For more details about the IC construction and functions, you can refer to the data sheet.
9.       ICSP Pin: (12)
Mostly, ICSP (12) is an AVR, a tiny programming header for the Arduino consisting of MOSI, MISO, SCK, RESET, VCC, and GND. It is often referred to as an SPI (Serial Peripheral Interface), which could be considered as an "expansion" of the output. Actually, you are slaving the output device to the master of the SPI bus.
10.   Power LED: (13)
This LED should light up when you plug your Arduino into a power source to indicate that your board is powered up correctly. If this light does not turn on, then there is something wrong with the connection or with the Arduino Board.
11.   TX and RX LEDs: (14)
On your board, you will find two labels: TX (transmit) and RX (receive). They appear in two places on the Arduino UNO board. First, at the digital pins 0 and 1, to indicate the pins responsible for serial communication. Second, the TX and RX led (14). The TX led flashes with different speed while sending the serial data. The speed of flashing depends on the baud rate used by the board. RX flashes during the receiving process.
12.   Digital I/O Pins: (15)
The Arduino UNO board has 14 digital I/O pins (15) (of which 6 provide PWM (Pulse Width Modulation) output. These pins can be configured to work as input digital pins to read logic values (0 or 1) or as digital output pins to drive different modules like LEDs, relays, etc. The pins labeled “~” can be used to generate PWM.
13.   AREF: (16)
AREF stands for Analog Reference. It is sometimes, used to set an external reference voltage (between 0 and 5 Volts) as the upper limit for the analog input pins.

For More Such Interesting Videos Please Visit our YouTube Channel Silly Tech TV

Wednesday, 9 November 2016

Arduino - Blink


Arduino Blink Example is one the most basic example in Arduino Library. This is basically used for testing a particular Arduino whether it is working correctly or not. It is most basic and very first example which is taught in Arduino tutorials.



In this example, a LED which is embedded on the Arduino Board starts blinking in the interval of 1 second. This LED can be found near Digit Pin – 13. This LED is directly connected to Pin – 13, so we can directly access this LED via Pin – 13.


Now, let’s check the code of the Blink Example and see how it works.


This is the Blink Example Project which you can find in File->Examples->Basic->Blink.


This is the code which do all the magic in the Arduino Board.


This block (function) of code defines different pin functionality as INPUT or OUTPUT.


This LED_BUILTIN is nothing but the Pin – 13 built–in LED, which can be directly accessed by Pin-13 itself.


This HIGH is nothing but ON or 1 (one) in Binary language which means pass the current.


This LOW is nothing but OFF or 0 (zero) in Binary language which means don’t pass the current.


Here we are waiting for 1000 ms which is equivalent to 1 second.


Like this the LED is ON for 1 second.


And like this the LED is OFF for 1 second.


This block (function) of code create a loop and make this ON and OFF of LED continuous, which is visible us as LED BLINKING.

For More Such Interesting Videos Please Visit our YouTube Channel Silly Tech TV.