LEDs are small, powerful lights that are used in many different
applications. To start, we will work on blinking an LED, the Hello World
of microcontrollers. It is as simple as turning a light on and off.
Establishing this important baseline will give you a solid foundation as
we work towards experiments that are more complex.
Labels
.
Search Your Article
Total Pageviews
Wednesday, January 25, 2017
Arduino - Fading LED
This example demonstrates the use of the analogWrite() function in
fading an LED off. AnalogWrite uses pulse width modulation (PWM),
turning a digital pin on and off very quickly with different ratios
between on and off, to create a fading effect.
Arduino - Reading Analog Voltage
This example will show you how to read an analog input on analog pin
0. The input is converted from analogRead() into voltage, and printed
out to the serial monitor of the Arduino Software (IDE).
Arduino - LED Bar Graph
This example shows you how to read an analog input at analog pin 0,
convert the values from analogRead() into voltage, and print it out to
the serial monitor of the Arduino Software (IDE).
Arduino - Keyboard Logout
This example uses the Keyboard library to log you out of your user
session on your computer when pin 2 on the ARDUINO UNO is pulled to
ground. The sketch simulates the keypress in sequence of two or three
keys at the same time and after a short delay, it releases them.
Arduino - Keyboard Message
In this example, when the button is pressed, a text string is sent to
the computer as keyboard input. The string reports the number of times
the button is pressed. Once you have the Leonardo programmed and wired
up, open your favorite text editor to see the results.
Arduino - Mouse Button Control
Using the Mouse library, you can control a computer's onscreen cursor with an Arduino Leonardo, Micro, or Due.
This particular example uses five pushbuttons to move the onscreen cursor. Four of the buttons are directional (up, down, left, right) and one is for a left mouse click.
This particular example uses five pushbuttons to move the onscreen cursor. Four of the buttons are directional (up, down, left, right) and one is for a left mouse click.
Arduino - Keyboard Serial
This example listens for a byte coming from the serial port. When
received, the board sends a keystroke back to the computer. The sent
keystroke is one higher than what is received, so if you send an "a"
from the serial monitor, you will receive a "b" from the board connected
to the computer. A "1" will return a "2" and so on.
Arduino - Humidity Sensor
In this section, we will learn how to interface our Arduino board
with different sensors. We will discuss the following sensors −
- Humidity sensor (DHT22)
- Temperature sensor (LM35)
- Water detector sensor (Simple Water Trigger)
Arduino - Temperature Sensor
The Temperature Sensor LM35 series are precision integrated-circuit
temperature devices with an output voltage linearly proportional to the
Centigrade temperature.
Arduino - Water Detector / Sensor
Water sensor brick is designed for water detection, which can be
widely used in sensing rainfall, water level, and even liquid leakage.
Arduino - PIR Sensor
PIR sensors allow you to sense motion. They are used to detect
whether a human has moved in or out of the sensor’s range. They are
commonly found in appliances and gadgets used at home or for businesses.
They are often referred to as PIR, "Passive Infrared", "Pyroelectric",
or "IR motion" sensors.
Following are the advantages of PIR Sensors −
Following are the advantages of PIR Sensors −
Arduino - Ultrasonic Sensor
The HC-SR04 ultrasonic sensor uses SONAR to determine the distance of
an object just like the bats do. It offers excellent non-contact range
detection with high accuracy and stable readings in an easy-to-use
package from 2 cm to 400 cm or 1” to 13 feet.
Arduino - Connecting Switch
Pushbuttons or switches connect two open terminals in a circuit. This
example turns on the LED on pin 2 when you press the pushbutton switch
connected to pin 8.
Arduino - DC Motor
In this chapter, we will interface different types of motors with the
Arduino board (UNO) and show you how to connect the motor and drive it
from your board.
There are three different type of motors −
There are three different type of motors −
Arduino - Servo Motor
A Servo Motor is a small device that has an output shaft. This shaft
can be positioned to specific angular positions by sending the servo a
coded signal. As long as the coded signal exists on the input line, the
servo will maintain the angular position of the shaft.
Arduino - Stepper Motor
A Stepper Motor or a step motor is a brushless, synchronous motor,
which divides a full rotation into a number of steps. Unlike a brushless
DC motor, which rotates continuously when a fixed DC voltage is applied
to it, a step motor rotates in discrete step angles.
Arduino - Tone Library
In this chapter, we will use the Arduino Tone Library. It is nothing
but an Arduino Library, which produces square-wave of a specified
frequency (and 50% duty cycle) on any Arduino pin.
Arduino - Wireless Communication
The wireless transmitter and receiver modules work at 315 Mhz. They
can easily fit into a breadboard and work well with microcontrollers to
create a very simple wireless data link. With one pair of transmitter
and receiver, the modules will only work communicating data one-way,
however, you would need two pairs (of different frequencies) to act as a
transmitter/receiver pair.
Arduino - Network Communication
The CC3000 WiFi module from Texas Instruments is a small silver
package, which finally brings easy-to-use, affordable WiFi functionality
to your Arduino projects.
It uses SPI for communication (not UART!) so you can push data as fast as you want or as slow as you want.
It uses SPI for communication (not UART!) so you can push data as fast as you want or as slow as you want.
Arduino - Useful Resources
The following resources contain additional information on Arduino. Please use them to get more in-depth knowledge on this.
Discuss Arduino
Arduino is a prototype platform (open-source) based on an easy-to-use
hardware and software. It consists of a circuit board, which can be
programed (referred to as a microcontroller) and a ready-made software
called Arduino IDE (Integrated Development Environment),
Apex - Overview
What is Apex?
Apex is a proprietary language which has been developed by Salesforce.com. As per the official definition, Apex is a strongly typed, object-oriented programming language that allows developers to execute the flow and transaction control statements on the Force.com platform server in conjunction with calls to the Force.com API.Apex - Environment
In this chapter, we will understand the environment for our
Salesforce Apex development. It is assumed that you already have a
Salesforce edition set up for doing Apex development.
Apex - Example
Enterprise Application Development Example
For our tutorial, we will be implementing the CRM application for a Chemical Equipment and Processing company. This company deals with suppliers and provides services. We will work out small code snippets related to this example throughout our tutorial to understand every concept deeply.Apex - Data Types
Understanding the Data Types
As we have studied, the Apex language is strongly typed so every variable in Apex will be declared with the specific data type. All apex variables are initialized to null initially. As a best practice developer has to make sure it should get assigned proper value otherwise such variables when used, will throw null pointer exceptions or any unhandled expections.Apex - Variables
Apex Variables
Java and Apex are similar in many manners. Variable declaration in Java and Apex is also quite same. Below are some examples to show how to declare local variables.String productName = 'HCL'; Integer i=0;
Apex - Strings
String in Apex, as in any other programming language, is any set of characters with no character limit.
Example:
Example:
String companyName = 'Abc International'; System.debug('Value companyName variable'+companyName);
Apex - Arrays
Arrays in Apex are basically the same as Lists in Apex. There is no
logical distinction between the Arrays and Lists as their internal data
structure and methods are also same but the array syntax is little
traditional like Java.
Apex - Constants
As in any other programming language, Constants are the
variables which do not change their value once declared or assigned a
value.
Apex - Decision Making
Decision making structures require that the programmer specify
one or more conditions to be evaluated or tested by the program, along
with a statement or statements to be executed if the condition is
determined to be true, and optionally, other statements to be executed
if the condition is determined to be false.
Apex - Loops
Loops are used when a particular piece of code should be repeated with
desired number of iteration. Apex supports the standard traditional for
loop as well as other advanced types of Loops. Lets have a more detailed
look on Loops In Apex.
Apex - Collections
Collections are the type of variable which can store multiple
number of records. For example, List can store multiple number of
Account object's records. Let's have a detailed overview of all
collection types.
Apex - Classes
Class Methods
There are two modifiers for Class Methods in Apex: Public or Protected. Return type is mandatory for method and if method is not returning anything then you must mention void as return type. Body is required for method.Apex - Objects
An instance of class is called Object. In terms of Salesforce,
object could be of class or you could create an object of sObject as
well.
Apex - Interfaces
What is an Interface?
An interface is like an Apex class in which none of the methods have been implemented. It only contains the method signatures, but the body of each method is empty. To use an interface, another class must implement it by providing a body for all of the methods contained in the interface.Apex - DML
In Salesforce, we could perform all the database modification functionalities by two ways:
DML Statements
DML are the actions which are performed in order to perform insert, update, delete, upsert, restoring records, merging records, or converting leads operation.
DML Statements
DML are the actions which are performed in order to perform insert, update, delete, upsert, restoring records, merging records, or converting leads operation.
Apex - Database Methods
Database class methods is another way of working with DML
statements which are more flexible than DML Statements like insert,
update etc.
Apex - SOSL
Every business or application has search functionality as one of
the basic requirements. For this, Salesforce.com provides two major
approaches using SOSL and SOQL:
Apex - SOQL
This is Salesforce Object Query Language designed to work with
SFDC Database. It can search a record on a given criteria only in single
sObject.
Like SOSL, it cannot search across the multiple objects but it does support nested queries.
Like SOSL, it cannot search across the multiple objects but it does support nested queries.
Apex - Security
Apex security refers to the process of applying security
settings and enforcing the sharing rules on running code. Apex classes
has security setting which can be controlled via two keywords.
Apex - Invoking
Apex invoking refers to the process of executing the Apex class.
Apex class can only be executed when it is invoked via one of the below
ways:
- Triggers and Anonymous block
- A trigger invoked for specified events.
- Asynchronous Apex
Apex - Triggers
Apex triggers are like stored procedures which execute when a
particular event occurs. It executes before and after an event occurs on
record.
Apex - Trigger Design Patterns
Design patterns are used to make our code more efficient and to avoid
hitting the governor limits. Often developers can write inefficient code
that can cause repeated instantiation of objects.
Apex - Governer Limits
Governor execution limits ensure the efficient use of resources on
the Force.com multitenant platform. It is the limit specified by the
Salesforce.com on code execution for efficient processing.
Apex - Batch Processing
Consider a scenario where you would like to process large number of
records on daily basis, probably the cleaning of data or maybe deleting
some unused data.
Apex - Debugging
Debugging is an important part in any programming development. In
Apex, we do have certain tools to use for debugging. One of them is
system.debug() method which prints the value and output of variable in
debug logs.
Apex - Testing
Testing is the integrated part of Apex or any other application
development. In Apex, we have separate test classes to develop for all
the unit testing.
Apex - Deployment
What is Deployment in SFDC?
Till now we have developed code in Developer Edition, but in real life scenario, you have to do this development in Sandbox and then you might need to deploy this to another sandbox or production environment and this is called as deployment.XStream - Overview
XStream is a simple Java-based library to serialize Java objects to XML and vice versa.
Features
- Easy to use - XStream API provides a high-level facade to simplify common use cases.
- No need to create mapping - XStream API provides default mapping for most of the objects to be serialized.
XStream - Environment Setup
Try it Option Online
We already have set up Java Programming environment online, so that you can compile and execute all the available examples at the same time when you are doing your theory work. This gives you confidence in what you are reading and to check the result with different options. Feel free to modify any example and execute it online.
XStream - First Application
Before going into the details of the XStream library, let us see an
application in action. In this example, we've created Student and
Address classes. We will create a student object and then serialize it
to an XML String. Then de-serialize the same XML string to obtain the
student object back.
XStream - Aliasing
Aliasing is a technique to customize the generated XML or to use a
particular formatted XML using XStream. Let's suppose, the following XML
format is to be used to serialize/de-serialize the Student object.
<student name="Suresh">
XStream - Annotations
XStream supports annotations similarly like automatic configuration
instead of coding. In the previous chapter, we've seen the following
configurations in code.
xstream.alias("student", Student.class); xstream.alias("note", Note.class);
XStream - Converters
XStream converters are the key components of the XStream library,
which are responsible to convert an object to XML and vice versa.
XStream provides numerous converters for common types such as
primitives, String, File, Collections, arrays, and Dates.
XStream - Object Streams
XStream provides alternative implementations of
java.io.ObjectInputStream and java.io.ObjectOutputStream so that streams
of objects can be serialized or de-serialized from XML. This is
particularly useful when large sets of objects are to be processed,
keeping one object in memory at a time.
XStream - Writing JSON using XStream
XStream supports JSON by initializing XStream object with an
appropriate driver. XStream currently supports JettisonMappedXmlDriver
and JsonHierarchicalStreamDriver.
Let us now test the code with json handling in XStream.
Let us now test the code with json handling in XStream.
XStream - Quick Guide
XStream - Overview
XStream is a simple Java-based library to serialize Java objects to XML and vice versa.Features
- Easy to use - XStream API provides a high-level facade to simplify common use cases.
- No need to create mapping - XStream API provides default mapping for most of the objects to be serialized.
XStream - Useful Resources
The following resources contain additional information on XStream. Please use them to get more in-depth knowledge on this topic.
Discuss XStream
XStream is a simple Java-based library to serialize Java objects to XML
and vice versa. This is a brief tutorial that adopts a simple and
intuitive way to explain the basic feature of XStream library and how to
use them.
XML Overview
What is XML?
XML is a simple text based language which was designed to store and transport data in plain text format. It stands for Extensible Markup Language. Following are some of the salient features of XML.Apache Xerces - Environment Setup
This chapter takes you through the process of setting up Apache
Xerces on Windows and Linux based systems. Apache Xerces can be easily
installed and integrated with your current Java environment following a
few simple steps without any complex setup procedures. User
administration is required while installation.
Apache Xerces XML Parsers
What is Apache Xerces2?
Xerces2 is a java based processor and provides standard interfaces and implementations for following XML parsing API standards:Apache Xerces - DOM Parser Overview
The Document Object Model is an official recommendation of the World
Wide Web Consortium (W3C). It defines an interface that enables programs
to access and update the style, structure,and contents of XML
documents. XML parsers that support the DOM implement that interface.
Apache Xerces DOM Parser - Parse XML Document
Steps to Using DOM
Following are the steps used while parsing a document using DOM Parser.- Import XML-related packages.
- Create a DocumentBuilder
- Create a Document from a file or stream
- Extract the root element
- Examine attributes
- Examine sub-elements
Apache Xerces Parser - Query XML Document
Demo Example
Here is the input xml file we need to query:<?xml version="1.0"?> <cars> <supercars company="Ferrari">
Apache Xerces Parser - Create XML Document
Demo Example
Here is the XML we need to create:<?xml version="1.0" encoding="UTF-8" standalone="no"?> <cars><supercars company="Ferrari">
Apache Xerces DOM Parser - Modify XML Document
Demo Example
Here is the input xml file we need to modify:<?xml version="1.0" encoding="UTF-8" standalone="no"?> <cars>
Apache Xerces SAX Parser - Overview
SAX (the Simple API for XML) is an event-based parser for xml
documents.Unlike a DOM parser, a SAX parser creates no parse tree.
SAX is a streaming interface for XML, which means that applications
using SAX receive event notifications about the XML document being
processed an element,
Apache Xerces SAX Parser - Parse XML Document
Demo Example
Here is the input xml file we need to parse:<?xml version="1.0"?> <class> <student rollno="393">
Apache Xerces SAX Parser - Query XML Document
Demo Example
Here is the input text file we need to Query for rollno: 393<?xml version="1.0"?> <class> <student rollno="393">
Apache Xerces SAX Parser - Create XML Document
It is better to use StAX parser for creating XML than using SAX parser. Please refer the Java StAX Parser section for the same.
Apache Xerces SAX Parser - Modify XML Document
Demo Example
Here is the input xml file we need to Modify by appending <Result>Pass<Result/>at the end of </marks> tag
<?xml version="1.0"?> <class>
Apache Xerces StAX Parser - Overview
StAX is a JAVA based API to parse XML document in a similar way as
SAX parser does. But there are two major difference between the two APIs
Apache Xerces StAX Parser - Parse XML Document
Demo Example
Here is the input xml file we need to parse:<?xml version="1.0"?> <class> <student rollno="393">
Apache Xerces StAX Parser - Query XML Document
Demo Example
Here is the input xml file we need to parse:<?xml version="1.0"?> <class> <student rollno="393">
Apache Xerces StAX Parser - Create XML Document
Demo Example
Here is the XML we need to create:<?xml version="1.0" encoding="UTF-8" standalone="no"?> <cars><supercars company="Ferrari">
Apache Xerces StAX Parser - Modify XML Document
Demo Example
In order to run this example, you should have jdom.jar in your application's classpath. Download jdom-2.0.5.zip.Here is the XML we need to modify:
<?xml version="1.0"?> <class>
Apache Xerces - Quick Guide
What is XML?
XML is a simple text based language which was designed to store and transport data in plain text format. It stands for Extensible Markup Language. Following are some of the salient features of XML.Apache Xerces XML Useful Resources
If you want to list down your website, book or any other resource on
this page then please contact at webmaster@tutorialspoint.com
TIKA - Overview
What is Apache Tika?
- Apache Tika is a library that is used for document type detection and content extraction from various file formats.
- Internally, Tika uses various existing document parsers and document type detection techniques to detect and extract data.
TIKA - Architecture
Application-Level Architecture of Tika
Application programmers can easily integrate Tika in their applications. Tika provides a Command Line Interface and a GUI to make it user friendly.TIKA - Environment
This chapter takes you through the process of setting up Apache Tika
on Windows and Linux. User administration is needed while installing the
Apache Tika.
TIKA - Referenced API
Users can embed Tika in their applications using the Tika facade
class. It has methods to explore all the functionalities of Tika. Since
it is a facade class, Tika abstracts the complexity behind its
functions. In addition to this, users can also use the various classes
of Tika in their applications.
TIKA - File Formats
File Formats Supported by Tika
The following table shows the file formats Tika supports.File format | Package Library | Class in Tika |
---|
TIKA - Document Type Detection
MIME Standards
Multipurpose Internet Mail Extensions (MIME) standards are the best available standards for identifying document types. The knowledge of these standards helps the browser during internal interactions.TIKA - Content Extraction
Tika uses various parser libraries to extract content from given
parsers. It chooses the right parser for extracting the given document
type.
For parsing documents, the parseToString() method of Tika facade class is generally used. Shown below are the steps involved in the parsing process and these are abstracted by the Tika ParsertoString() method.
For parsing documents, the parseToString() method of Tika facade class is generally used. Shown below are the steps involved in the parsing process and these are abstracted by the Tika ParsertoString() method.
TIKA - Metadata Extraction
Besides content, Tika also extracts the metadata from a file.
Metadata is nothing but the additional information supplied with a file.
If we consider an audio file, the artist name, album name, title comes
under metadata.
TIKA - Language Detection
Need for Language Detection
For classification of documents based on the language they are written in a multilingual website, a language detection tool is needed. This tool should accept documents without language annotation (metadata) and add that information in the metadata of the document by detecting the language.TIKA - GUI
Graphical User Interface (GUI)
- Tika provides a jar file along with its source code in the following link http://tika.apache.org/download.html.
- Download both the files, set the classpath for the jar file.
TIKA - Extracting PDF
Given below is the program to extract content and metadata from a PDF.
import java.io.File; import java.io.FileInputStream; import java.io.IOException;
TIKA - Extracting ODF
Given below is the program to extract content and metadata from Open Office Document Format (ODF).
import java.io.File; import java.io.FileInputStream; import java.io.IOException;
TIKA - Extracting MS Office Files
Given below is the program to extract content and metadata from a Microsoft Office Document.
import java.io.File; import java.io.FileInputStream; import java.io.IOException;
TIKA - Extracting Text Document
Given below is the program to extract content and metadata from a Text document:
import java.io.File; import java.io.FileInputStream; import java.io.IOException;
TIKA - Extracting HTML Document
Given below is the program to extract content and metadata from an HTML document.
import java.io.File; import java.io.FileInputStream; import java.io.IOException;
TIKA - Extracting XML Document
Given below is the program to extract content and metadata from an XML document:
import java.io.File; import java.io.FileInputStream; import java.io.IOException;
TIKA - Extracting .class File
Given below is the program to extract content and metadata from a .class file.
import java.io.File; import java.io.FileInputStream; import java.io.IOException;
TIKA - Extracting JAR File
Given below is the program to extract content and metadata from a Java Archive (jar) file:
import java.io.File; import java.io.FileInputStream; import java.io.IOException;
TIKA - Extracting Image File
Given below is the program to extract content and meta data from a JPEG image.
import java.io.File; import java.io.FileInputStream; import java.io.IOException;
TIKA - Extracting mp4 Files
Given below is the program to extract content and metadata from mp4 files:
import java.io.File; import java.io.FileInputStream; import java.io.IOException;
TIKA - Extracting mp3 Files
Given below is the program to extract content and metadata from mp3 files:
import java.io.File; import java.io.FileInputStream; import java.io.IOException;
TIKA - Quick Guide
TIKA - Overview
What is Apache Tika?
- Apache Tika is a library that is used for document type detection and content extraction from various file formats.
- Internally, Tika uses existing various document parsers and document type detection techniques to detect and extract data.
- Using Tika, one can develop a universal type detector and content extractor to extract both structured text as well as metadata from different types of documents such as spreadsheets, text documents, images, PDFs and even multimedia input formats to a certain extent.
- Tika provides a single generic API for parsing different file formats. It uses 83 existing specialized parser ibraries for each document type.
- All these parser libraries are encapsulated under a single interface called the Parser interface.
Why Tika?
According to filext.com, there are about 15k to 51k content types, and this number is growing day by day. Data is being stored in various formats such as text documents, excel spreadsheet, PDFs, images, and multimedia files, to name a few. Therefore, applications such as search engines and content management systems need additional support for easy extraction of data from these document types. Apache Tika serves this purpose by providing a generic API to locate and extract data from multiple file formats.Apache Tika Applications
There are various applications that make use of Apache Tika. Here we will discuss a few prominent applications that depend heavily on Apache Tika.Search Engines
Tika is widely used while developing search engines to index the text contents of digital documents.- Search engines are information processing systems designed to search information and indexed documents from the Web.
- Crawler is an important component of a search engine that crawls through the Web to fetch the documents that are to be indexed using some indexing technique. Thereafter, the crawler transfers these indexed documents to an extraction component.
- The duty of extraction component is to extract the text and metadata from the document. Such extracted content and metadata are very useful for a search engine. This extraction component contains Tika.
- The extracted content is then passed to the indexer of the search engine that uses it to build a search index. Apart from this, the search engine uses the extracted content in many other ways as well.
Document Analysis
- In the field of artificial intelligence, there are certain tools to analyze documents automatically at semantic level and extract all kinds of data from them.
- In such applications, the documents are classified based on the prominent terms in the extracted content of the document.
- These tools make use of Tika for content extraction to analyze documents varying from plain text to digital documents.
Digital Asset Management
- Some organizations manage their digital assets such as photographs, e-books, drawings, music and video using a special application known as digital asset management (DAM).
- Such applications take the help of document type detectors and metadata extractor to classify the various documents.
TIKA - Useful Resources
The following resources contain additional information on Apache
TIKA. Please use them to get more in-depth knowledge on this topic.
Discuss TIKA
This tutorial provides a basic understanding of Apache Tika library, the
file formats it supports, as well as content and metadata extraction
using Apache Tika.
Subscribe to:
Posts (Atom)