Search for more details......

Micro Controllers.

Micro Controllers


Micro controller is a electronic device(IC) and which is small computer built as a one component. In a micro controller, there are many modules built in for cut down external components to be used with it.





General Internal Modules in Micro Controllers.
  • Analog to Digital Converter,
  • Timers,
  • Oscillators
  • SPI Bus,
  • I2C,
  • RS232(serial),
  • Parallel  ports,
  • USB, PWM(Pulse Width Modulation),
  • Interrupts generators,


Features of Micro Controllers

  • Very low power consumption is better for battery powered devices.
  • Programming and designing is very easy than Micro Processors.
  • There are thousands of micro controller models in the market with different capabilities. 
  • Low cost.
  • Easy to program and design than Micro processors.
  • Working without any other external components(not all).
  • Re-programmable internal Flash Memory
  • Save more space of the circuit board and decrease additional components. 
  • Assembly, C, C++,Java supported.
  • Project boards for testing and for studying usages.



 

Changing Colors Using For Loops

Changing Colors Using For Loops

You can change color at the run-time to generate different colors. Following example shows how to do it Java.



Many computer languages as well as Java, use three or four integers to represent a color. There are many color profile used in the world.

Example,

  • RGB(Red, Green, Blue),
  • CMYK(Cyan, Magenta, Yellow, Black),
  • RGBA(Red, Green, Blue, Alfa), act.   



 In programming, All sub elements of these profiles are represented by integer values.

Example,

       RGB-  Red      -Integer  (0-255)
                  Green   -Integer  (0-255)
                  Blue     -Integer   (0-255)

                As shown in the above example we can represent a RGB color using three integers. Value range is form zero  to 255. So, for red color, 255, 0, 0 and for Green color, 0, 255, 0 and for Blue color, 0, 0, 255.

When we want to create a mixed color we can give different values for these fields.

0,0,0 is black.
255,255,255 is white
255,255,0 is Yellow
100,100,100 is Gray


Change colors using loops.


for(int red=0;red<256;red+=10){

  for(int green=0;green<256;green+=10){

      for(int blue=0;blue<256;blue+=10){
          //Create new Colors for labels.
          Color color=new Color(red,green,blue);
          

          //Create Labels
          JLabel label=new JLabel(" Colored Text ");

          //Set Created Color to JLable.
          label.setColor(color);
                              
          add(label);


      }

  }    

}


Add this code into  your Java program that is created using a JFrame and run. You can see different colored texts.


SQLite for Java










SQLite for JDBC

Description

 

SQLite is a open source database engine that can be connected to Java through SQLite JDBC Driver. You can create portable SQL database using SQLite.


Connection

 

To define a database,  set the connection string to the driver class. If the database specified is not exists, a new file created automatically. Now you can execute SQL commands to manage your database.

Requirements

 

SQLite JDBC Driver jar (sqlite-jdbc-<version>.jar)

You can download it form http://www.javaworkspace.com/connectdatabase/connectSQLite.do



Installation

 

Copy driver jar file into your Java project and add it to class path. If you use a IDE to develop your Java application, you can simply add the jar file into your project.
Now, SQLite database engine is ready to work with your Java application.


Examples and Code Samples


Create Connection

Following code segment is for initializing database engine and connect to the database file using SQLite JDBC driver. After executing this code  automatically creates a database file (d:\\sqlite.db)

try {
   

  Class.forName("org.sqlite.JDBC");
  Connection c= DriverManager.getConnection("jdbc:sqlite:d:\\sqlite.db");
 
           
              
} catch (Exception ex) {
  ex.printStackTrace();  
}


Creating Table


When you want to create a new table you can execute normal SQL commands for it. After executing this code segment, it will create a table named 'myTable' on the database file.

try {
   

  Class.forName("org.sqlite.JDBC");
  Connection c= DriverManager.getConnection("jdbc:sqlite:d:\\sqlite.db");
  c.createStatement().executeUpdate("CREATEtable myTable(id int,name varchar(50))");
           
              
} catch (Exception ex) {
  ex.printStackTrace();  
}


Inserting Data


Now we have to insert data into the table we created using above code. After executing the insert query, it will insert data into the table. I have given values here are, 1 for column id and Saman for column name.

try {
   

  Class.forName("org.sqlite.JDBC");
  Connection c= DriverManager.getConnection("jdbc:sqlite:d:\\sqlite.db");
  c.createStatement().executeUpdate("INSERT INTO myTable VALUES('1','Saman')");           
              
} catch (Exception ex) {
  ex.printStackTrace();  
}





Fetching Data

 

Then you can get values from the data base using select query. Following code segment will fetch

try {
   

  Class.forName("org.sqlite.JDBC");
  Connection c= DriverManager.getConnection("jdbc:sqlite:d:\\sqlite.db");


  ResultSet rs=c.createStatement().executeQuery("SELECT * FROM myTable");
           
  while(rs.next()){
           
    System.out.println(rs.getInt("id")+" "+rs.getString("name"));
               
                            }
  rs.close();          
              
} catch (Exception ex) {
  ex.printStackTrace();  
}


If you have any question, you can comment or email me.

Low Cost Power Supply

Capacitor Power Supply

When you want to get a small current at low voltages from the mains current(230V AC), you have to step down  it using a power supply(Transformer, SMPS). But when you want a small current less than 50mA, you can use very inexpensive method to do it.  For example, you want to create a LED light for your room. Use a capacitive power supply for it.

Capacitive power supply is a very small circuit, it is used as power supply in very low power requirements from the direct mains current.

CAUTION!
The circuit is not galvanically isolated from the mains. Touching any part of the circuit (or any circuitry it supplies power to) while in operation, is dangerous and can result in an electric shock! This circuit should not be built or used by individuals without proper knowledge of mains voltage procedures.






 







This is a 9V power supply circuit diagram and you can change the output voltage by using a different zenor diode. I have used it as 9V so this power supply gives 9V. You can use series of 3 LEDs to connect to this circuit to make a LED light or you can use for your any requirements. You can make this power supply circuit with cost lower than 0.5$.

If you want to know more, leave a comment.


Online Jobs

If you want to work at Home, read this article.


How can I work online.


If you have a internet connection and a computer, you can start online job. But how?. There are many online job bank for find a job for you as part time or full time. I am telling you a website that is the very popular website in the world that helps to unemployed people around the world. If you have skills so you can start your job now!. I am telling about Freelancer.





Freelancer?


Hey, what is freelancer. How about online jobs?. Yes, I am telling about online jobs though working as a freelancer. If you have skills to doing somethings like programming, data entering(like word excel), graphics designing or many more. But it is very easy to start but many people who work at freelancer, failed withing few days and their dreams not come to true. That's because they don't know how to be a good freelancer.


Freelancer is an automated website that let employers and employees to connect each other though a small window!. There are many jobs(part time and full time) in freelancer are called projects. But you can't get any project without biding it. That is the hardest part of a freelancer.

Free Lancer Default Page.



















Stop talks and start working. Now be a Freelancer by registering on it. Freelancer is free. Go to Freelancer by clicking this link www.freelancer.com. Sign up on this site by clicking sign up button in left top corner.

After registering on Freelancer as a freelancer, first you can face and pass exams which will increase your earning. There are free and paid exams, so you can pass exams according to your skills.  You will be guided by this web application and you can see your progress on the top of the page.

When you win a bid, then you can complete the job correctly timely, so you will be a get top rank on it. There are thousands of projects and you can bid them and complete the job and get paid.

Thank You.

If you want more details, please leave a comment.




 

Finding vars in java source file using java

You can write a program that search for given variable types. This is example program for searching double float and int Variables. You can change the logic of if statement which are written with sCurrentLine.contains("float") like statements.





import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class TraceVarsInSource {

    public static void main(String[] args) {

        BufferedReader br = null;

       

        try {

            String sCurrentLine;
//Set the source file.
            br = new BufferedReader(new FileReader("D:\\workspace\\Secure_Packager\\src\\sun\\security\\Sun_Secure_Packager.java"));

            while ((sCurrentLine = br.readLine()) != null) {

//Check for var types.                              if(sCurrentLine.contains("double")||sCurrentLine.contains("float")||sCurrentLine.contains("int")){                                     String []data=sCurrentLine.split("=");
                                     if(data.length>1)
                                     System.out.println("Found Variable:"+data[0].trim()+"\tValue:"+data[1]);
                              }
               
            }

        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (br != null)br.close();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }

    }
}

Why My Computer is Extremely Slow




Do you want to eat your computer!


Before eating, read this and correct problem with your computer. Because of always not the fault with you computer, the problem with you!. 


We have to know why is the computer is getting slowing.



  • Virus attacks
  • Software Errors
  • No Free Space
  • Insufficient Hardware
  • No Maintains.




Virus Attacks

 

The main reason for slowing a computer is Viruses. There are billions of computer viruses made for varies reasons. But problem is how can you know that your computer is attacking by a virus? This is the biggest problem for many of computer owners. If you are a good programmer, you know what is the attack and how to retreat it and how to safe your computer. But most of the people, they can't do by ti them self.

There are many virus attack type. Windows xp is very unsecured operating system from the Microsoft. But Windows 7 has developed with many patches and harder to attack to it. If a virus which is transferred to a computer can used to control your computer through internet or it can be uploaded your personal data to the internet(credit card numbers like things) and so on............

Some viruses made for slow down the computer or corrupt you operating system damage your files. Many of these viruses are made by beginner who like to learn about viruses. 

You can safe from viruses with installing a powerful antivirus program. If you use internet, you must use a internet security version of the antivirus program. (Kaspersky,Avast,Avira)


Is is possible to remove a virus.

If you have a good antivirus program so you don't want to get a more risk about your data. Because of the antivirus on your computer will automatically detect the virus and remove for move to a secured area like a prison.

After attacking a virus to your computer, sometimes you can remove it using a antivirus, but you can't to be safe. Because of the virus is run already and it could be spread to you file system.(Some viruses copied to folder 'System Volume Information' on the drive and attached to backup data. So, when we trying to recover the system the virus is runs again through the backup data. First thing is for a virus is spread securely and damage the security on the computer.  While doing these things your computer is getting slower and slower. Other reason is for slowing, the antivirus trying to detect and block virus action, so performance of the computer is reduced.

So you have few chances to be safe your computer after a virus attack. You can format and re-install your operating system with all of disk drives.






Software Errors

Another reason for the slowing a computer is Software Errors. You know the main software is the Operating System. Errors on the operating system is very very like to virus attack!, because of many viruses first attack to the operating system to crack the security. After that, you have broken operating system without security!. 

Software errors could be occurred through varies thing. If you don't shutdown your computer it is a reason for damage software including operating system. You can run this command though the command prompt to fix errors of file system

CHKDSK /F

You may asked a long question, press y to continue it at the next boot.

Unfortunately you can't correct many of software errors without reinstalling them.



 



 No Free Space


When the free space of the windows drive is lowing, the computer is slowing!. Because of not space to make temp files and harder to read disk when it is full.(more harder to handle data request from physical devices like hard disk drive when they full).

So you can run your Disk Cleanup to clean unwanted files to free up the disk. 
To do this type DISKMGR on the run or CMD or other way. You have to clean your hard disk drive once a week or month. 

Don't put your files in the Windows Drive(C:\)
If you  have thousands of small files, you can create a one compressed file for all of them.







Insufficient Hardware

Physical devices like RAM,Processor,Hard Disk could be the reason for slowing computer. Open Task manager(Performance Tab) to see usage of RAM and CPU. If it's graph is filled so you can add or replace the that device.




No maintains 

The computer do all the things what your want. But do you do any work of you computer! You have to maintain you computer timely. I write here a trick, how to speed up the computer though hard disk.

You can run the Disk Cleanup as I maintained earlier.

Then open Disk Defragmenter tool(Start Menu>All Programs>Accessories>System Tools>Disk Defragmenter. 




Click on the defragment button to defrag you hard disk drives one by one. This may take more time(hours) and speed up your computer.

Do this one a month, if not slow again.


Now You can do this all Before Eating your Computer!





One Trick to Restore System Files on your computer!

 

 

Insert A original windows CD/DVD into a optical drive
Open to 'Run'  or 'Command Prompt' using start menu or by pressing Win Logo Key + R.

Type sfc /scannow and press Enter

It will take a few minutes to check virus effected or damaged System files and reinstall them again.

This process may take one restart, so close every programs running on your computer before run this command.