Skip to main content

Posts

Showing posts from March, 2014

JAVA BASICS - HOW TO USE A STRING IN SWITCH STATEMENTS

Simple example to switch statements using string. Syntax : switch(String variable) { case "" : case "" : case "" : : : . } Example : public class StringSwitchDemo { public static void main(String[] args) {                StringSwitchDemo demo = new StringSwitchDemo();                String day = "Sunday";                switch (day)                {                               case "Sunday":                               demo.doSomething();                               break;                               case "Monday":                               demo.doSomethingElse();                               break;                               case "Tuesday":                               case "Wednesday":                               demo.doSomeOtherThings();                               break;                               default:                      

JDBC - JAVA DATABASE CONNECTIVITY

Java Database connectivity: JDBC is not that difficult as it seem to. Following steps will guide you to set up a java database connection. In the end a simple example will get you the clear idea of how this thing actually works. Step 1: Firstly open "Data Sources".  Start -> Control panel ->Administrative tools -> Data Sources Now you have to add data source that JDBC - ODBC bridge driver can open. To do so click add and the following dialog will appear. Make sure you select Microsoft Access Driver driver as shown above and click finish. In the next screen enter the name of data source name. This is the name you will be using in your java code to open your database, also enter description. Use select button to browse your MS access file that you have created. Click ok .Your database will now be in the list of data source.  Following is the sample java code that will help you to interface your database file. import java.sql.*;

SEQUENCER

Title: Sequencer Circuit: Components: IC 555 IC 4017 Resistor: 1 M 470 ohms    x 10 Capacitor: 0.1 uf Battery: 9 - 12 volt Description: The model 4017 integrated circuit is a CMOS counter with ten output terminals. One of these ten terminals will be in a "high" state at any given time, with all others being "low," giving a "one-of-ten" output sequence. If low-to-high voltage pulses are applied to the "clock" (Clk) terminal of the 4017, it will increment its count, forcing the next output into a "high" state. With a 555 timer connected as an astable multivibrator (oscillator) of low frequency, the 4017 will cycle through its ten-count sequence, lighting up each LED, one at a time, and "recycling" back to the first LED. The result is a visually pleasing sequence of flashing lights. Feel free to experiment with resistor and capacitor values on the 555 timer to create different flash rate

SIMPLE METAL DETECTOR

Title :  A Simple metal detector Circuit:  Components: Capacitor: 1000 uf   x 1 4.7 nf      x 1  10 nf       x 2   Resistor: 10 k (variable resistor) 1 k Oscillator:     x2  40 Khz Miscellaneous: Switch 9v battery Piezo sounder Enammeled copper wire Description: This circuit uses a single coil and nine components to make a particularly sensitive low-cost metal locator. It works on the principle of a beat frequency oscillator (BFO). The circuit incorporates two oscillators, both operating at about 40kHz. The first, IC1a, is a standard CMOS oscillator with its frequency adjustable via VR1. The frequency of the second, IC1b, is highly dependent on the inductance of coil L1, so that its frequency shifts in the presence of metal. L1 is 70 turns of 0.315mm enamelled copper wire wound on a 120mm diameter former. The Faraday shield is made of aluminium foil, which is wound around all but about 10mm of the coil and connected to pin 4 of IC1b. The

HEART RATE MONITOR

Title: Heart Rate Monitor Circuit: Components: Resistors: 100 k x 2 3.3 M x 2 15 k x 2 220 k x 1 10 M OPamps: x 2 Capacitor: 0.1 uf 4.7 uf 10 uf Battery:  A 9v battery Miscellaneous: Multimeter: LDR:(Z-4801) Switch:  Description: The secret is a high gain circuit, based on a dual op amp IC which can be either the low power LM358 or the JFET TL072. The LDR is connected in series across the 9V battery supply via a 100kO resistor (R1) and the minute signal caused by the blood pulsing under the skin is fed to the non-inverting (+) input, pin 3, of IC1a via a 0.µF capacitor. Pin 3 is biased by a high impedance voltage divider consisting of two 3.3MO resistors. The feedback resistors to pin 2 set the gain to 11 times. The output of IC1a is fed via a 0.47µF capacitor and 220kO resistor to IC1b. This is configured as an inverting op amp with a gain of 45 so that the total circuit gain is about 500. The output of IC1b is used to drive an an

HOW TO ADD BACKGROUND IMAGE IN JAVA SWING

The simple example to insert an image to background of frame in java Syntax : ImageIcon("Path-to-imagefile//image_name.its-extension"))); Example :  import javax.swing.*; import java.awt.*; import java.awt.event.*; class BackgroundImageJFrame extends JFrame { JButton b1; JLabel l1;                public BackgroundImageJFrame()                {                setTitle("Background Color for JFrame");                 setLocationRelativeTo(null);                setDefaultCloseOperation(EXIT_ON_CLOSE);                setVisible(true);                  setContentPane(new JLabel(new                                                                          ImageIcon("C:\\Users\\Public\\Pictures\\Sample                                                    Pictures\\Penguins.jpg")));                setLayout(new FlowLayout());                l1=new JLabel("Here is a button");                b1=new JButton("I am a button"

HOW TO CONFIGURE ANDROID IN ECLIPSE

Simple way to configure android in eclipse. Step 1: Download the ADT Plugin Start Eclipse, then select Help > Install New Software. Click Add, in the top-right corner. In the Add Repository dialog that appears, enter "ADT Plugin" for the Name and the following URL for the Location: https://dl-ssl.google.com/android/eclipse/ Click OK. If you have trouble acquiring the plugin, try using "http" in the Location URL, instead of "https" (https is preferred for security reasons). In the Available Software dialog, select the checkbox next to Developer Tools and click Next. In the next window, you'll see a list of the tools to be downloaded. Click Next. Read and accept the license agreements, then click Finish.If you get a security warning saying that the authenticity or validity of the software can't be established, click OK. When the installation completes, restart Eclipse. Step 2:Download the ADT Plugin Once Eclipse restarts, y