Showing posts with label hello world. Show all posts
Showing posts with label hello world. Show all posts

Sunday, February 8, 2015

Your First Java Program: Hello World




In this section, our plan is to lead you into the world of Java programming by taking you through the three basic steps required to get a simple program running. The Java system is a collection of applications not unlike any of the other applications that you are accustomed to using  browsers etc. As with any application, you need to be sure that Java is properly installed on your computer. You also need an editor (notepad , wordpad etc) and a terminal application(command prompt etc). 

Programming in Java. We break the process of programming in Java into three steps:

1. Create the program by typing it into a text editor and saving it to a file named,  say, helloworld.java.
2. Compile it by typing "javac helloworld.java" in the command prompt window.
3. Run (or execute) it by typing "java helloworld " in the command prompt window.

The first step creates the program; the second translates it into a language more suitable for machine execution (and puts the result in a file named helloworld.class);the third actually runs the program.
1.      Creating a Java program. A program is nothing more than a sequence of characters, like a sentence, a paragraph, or a poem. To create one, we need only define that sequence characters using a text editor in the same way as we do for e-mail. helloworld.java is an example program. Type these character into your text editor and save it into a file named helloworld.java.




Remember that the file name should be same as the program class name.


2.      Compiling a Java program. At first, it might seem to you as though the Java programming language is designed to be best understood by the computer. Actually, to the contrary, the language is designed to be best understood by the programmer (that's you). A compiler is an application that translates programs from the Java language to a language more suitable for executing on the computer. It takes a text file with the .java extension as input (your program) and produces a file with a .class extension (the computer-language version).


Open cmd.exe window.







Give a path to that drive where you have stored your helloprogram.java file (mine is M drive) 






Create a folder java in your drive and move the .java file in that folder and open the folder in cmd window (cd command is used to open a folder).



Now open the program file by writing “javac helloworld.java” , this will create a class file




 











3.      Executing a Java program. Once you compile your program, you can run it. This is the exciting part, where the computer follows your instructions. To run the helloworld program, type the following at the cmd window:
               “     java helloworld      ”



OUTPUT






Also feel free to ask any doubts regarding the projects.







-Manish :)

Saturday, February 7, 2015

"HELLO WORLD" IN AVR - LED BLINKING & WRITING / SIMULATING YOUR FIRST PROGRAM

Hello & welcome to the first tutorial on AVR

This tutorial is focused on imparting basic AVR knowledge to folks interested in beginning in embedded systems & robotics.

The very first post is on the "HELLO WORLD" in robotics (specifically AVR).
I'd suggest you kindly clear your basics of digital electronics before starting this tutorial.
Also learn to read data sheets of basic IC's such as the following:


  1. 555 timer.
  2. max232
  3. opamp 741
  4. lm35
  5. adc0804
  6. ATtiny
& our first microcontroller  ATMEGA 16.
FOR beginning the set of tutorials, we'll download "WINAVR setup" & install it onto the desktop. & open the PROGRAMMER's NOTEPAD.



1) select file->new->c/c++ file to compose your first AVR program
2) write the given program & save it at a desired location in a separate folder

3) Now find the makefile & edit it.


4) to Edit makefile, select the desired F_CPU speed (Preferably 8000000 or 16000000) & also change the TARGET FILE NAME to the name of your own progam saved with programmer's notepad. & then save the makefile using File->save as on top left of makefile. SAVE THE MAKEFILE IN THE SAME FOLDER AS YOUR PROGRAM.C . 
5) After storing your own program file & makefile in the same folder. Click on Make Clean & Make All.
check for ZERO ERRORS in the dialog box below. & proceed.
Congrats, You have compiled your first AVR PROGRAM USING PROGRAMMER'S NOTEPAD.

6) Your project Folder will appear similar to this after step 5. It will have the "program.c" file as well as makefile & the "program.hex" file. & a bunch of other files whose use we'll discuss in the coming tutorials.

& Now , moving on to our next software Proteus. Its an animated software simulation method of your circuits.
Google this Software. You'll find plenty of good download links with FULL SETUP (SOFTWARE + CRACK+ LICENSE KEY). So Download & install the setup using the "HOW TO TEXT FILE".
7)Using the part list library within Proteus. Make the connections & Construct this basic circuit. 
8) Save the design file for your ease in the same folder as your AVR project folder. I advise you make a folder for each project in the coming tutorials & save it with the title name of your project.
eg. :  LED_BLINKER_TEST folder
              > LED_BLINKER.c
              >LED_BLINKER.hex
              >LED_BLINKER.dsn
              >makefile



9)Now lets add the hex program to the Proteus circuit for software simulation. for that click
SOURCE->Add/remove source file-> & select the target processor as the microcontroller in the design. for our design we chose atmega16. & click new to select the source file . CLICK & SELECT THE .HEX FILE from the project folder & proceed.

10) Now after adding the Hex file to design. click Execute & the click on the green Play button on the bottom left to Simulate. & use pause/play/stop button as & when you require.
After following all steps properly, You'll see the Animated led glowing after a specific delay.



Next, we'll Focus On BURNING the program to a real hardware using AVRDUDE .
Open AVRDUDE GUI & make the following settings:
i.e set your controller(we are using atmega16), programmer/burner (i am using usbasb), com port(check for ComPort by looking into the device manager for New hardware. This will pop up everytime you connect a new controller/device to your pc ), high fuse & low fuse.
Select the hex file & execute.

As my device is not connected to the machine. you see the message below.

 




when you connect your device , you'll see it in the device manager.
while programming, select the same COM PORT (COM3 in this case ) while programming.





You may use a common AVR burner hardware & connect the controller on a development board or breadboard & program the controller to see the led connected to C- bit 1, blinking.








































For all of you who are yet confused about the fuses , i'll do a separate comprehensive tutorial on 
  • AVR FUSES of some common AVR controllers.
  • TIMERS /DELAYS & INTERRUPTS
  • SERIAL & PARALLEL COMMUNICATION

Also feel free to ask any doubts regarding the projects.







-Abhirup :)