Friday, September 20, 2013

Simple Kitchen Computing Interface: Wiimote + Laptop







Step 1: Assemble your materials

You will need:

One Wii remote

One sacrificial/reusable/sanitary pouch for your wiimote (I use a sandwich bag and then wash it with the rest of the dishes—make sure it is completely dry before you reuse it!)

One bluetooth-capable laptop, netbook, or equivalent with a recent install of Processing

Wiimote-interpreting software. I use Osculator, which is free for awhile and then ~$30 to keep. It comes in handy for many things, so I consider the purchase to be well worth it. If you don't want to spend any money, you can try doing ti all in Processing, Flash, or Java; they all have pretty good wiimote libraries.

Step 2: Prepare Wii remote

           Just put the wiimote in the bag, press the air out, and seal it. Use two bags if you're paranoid.

Step 3: Set up your Wiimote-to-laptop routings

        Download the attached Osculator patch and save it somewhere convenient.

Download the attached Processing sketch and save it in the same place.

Guess What: You have to be an Instructables member to be able to download attachments! And, Instructables does not preserve file names or extensions! So, no files included here. Instead, head to http://github.com/AKAMEDIASYSTEM/KitchenWiimoteInterface and get everything you need over there.

Open the Osculator patch and connect your Wiimote - make sure the Wiimote you use is set as "Wii 1" in the Wiimote Drawer of Osculator.

Start the Processing sketch.

Using the keyboard, make VLC is the foreground application and Firefox is behind it (ie, so that in VLC pressing Command-Tab gets you to Firefox, and vice versa).

Stark cooking!

Please see the attached diagrams for a summary of button-to-function mappings for VLC and Firefox.

 

Step 4: Cook!

           You're done - now you can watch movies and consult recipes while you have your hands deep inside a turkey! The Wiimote will work from inside a turkey too!

Step 5: Do more / Next Steps

KNOWN QUIRKS:

- The system assumes that VLC is in the foreground when you start. It assumes from then on that you are just switching between Firefox and VLC. You can re-write the scripts to include an arbitrary number of applications and behaviors, though...have at it!

- The system works best with a quick click of the B button rather than a long press. You might have to practice once or twice to get the timing right.

DO MORE:

- I've attached a blank wiimote template in .ai format if you'd like to alter the patches and make your own mappings.

- I've done my best to comment the (very straightforward) Processing sketch in a helpful way. The code is also available on github

Browse through some other Instructables to get ideas about where this could go; this one was only the beginning! Think about what it means to have an inexpensive, expressive, handsfree input device that can take the place of a keyboard and mouse for many tasks.

If you own a small projector, lucky you! Now you can mount it over your countertop and turn your food prep surface into a display! Or even better:

http://www.instructables.com/id/Low-Cost-Multi-touch-Whiteboard-using-the-Wii-Remo/

If you own a webcam or some IR light pens, you could make this a display AND a multitouch input, even if your hands are covered in dough!

Turn your Arduino Uno into an USB-HID-Mididevice


Step 1: Gather your materials

Things you need:
- A compatible Arduino board. I'm using the Arduino Uno here.
- An AVR-ISP programmer. The AVRISP mkII works great and is used here.
- Software to use your ISP programmer; up and running. I'm using the AVR crosspack with avrdude on my MacBook Pro.
- The HIDUINO software from here http://code.google.com/p/hiduino/downloads/list

To get ready for the next steps you have to unpack the HIDUINO archive.

In the unpacked file move to the folder "Arduino Libraries". Inside you will find another folder called "HIDUINO_MIDI_Lib".
Move this folder into your Arduino - Libraries folder.
The final result should look like this /Users/phil/Documents/Arduino/Libraries/HIDUINO_MIDI_Lib

We haven't moddified the original USB firmware yet, so it's still intact and you can use it to flash an example sketch to your Arduino.
Try the first sample from the HIDUINO archive. It's located under "Arduino Example Sketches" and really easy to understand.
You don't have to do this yet, but it allows you to test your device immediately after reflashing the USB firmware.

Step 2: Programming the new USB firmware

                Okay, the first thing we want to do is to reflash the Uno's 8u2 chip.
Therefore we need to do the following:

- Connect your ISP to your Arduino. (Be sure to connect it in the right way! The pinheader should be marked with a little white dot! It marks pin number one! On the ISP cable it's marked with a little arrow.)
- We want to flash the following file: HIDUINO/CompiledFirmwares/HIDUINO_MIDI_Uno.hex
- I'm using avrdude in a terminal window on my Mac. I used the following command  for an Arduino Uno and an AVRISP mkII:
avrdude -p at90usb82 -F -P usb -c avrispmkii -U flash:w:HIDUINO_MIDI_Uno.hex -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m

- after 6-10 seconds the new firmware should be flashed successfully! Your device should show up in your system profiler now! If not just unplug it and replug it back again :) Then you can move on to the next step! :)

- In case you want to restore the original frimware of the 8u2 you can find it in your Arduino application folder. On a Mac its located under:
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/firmwares/UNO-dfu_and_usbserial_combined.hex
- Reflash it using avrdude an this command:
avrdude -p at90usb82 -F -P usb -c avrispmkii -U flash:w:UNO-dfu_and_usbserial_combined.hex -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m

There are tons of instructables and tutorials on how to flash an AVR using avrdude. This is just a short sum up of paths and commands ;)

Step 3: Programming the Uno using ISP

             After successfully flashing the USB firmware you can't upload sketches over usb anymore.

I wanted to keep the ability of using the Arduino software to upload the sketches over ISP.
Therefore you have to edit the boards.txt located under: /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/boards.txt

Add the following code to the textfile and save it.

##############################################################

avrispmkii.name=AVRISP mkII w/ ATmega328

avrispmkii.upload.protocol=avrispmkii
avrispmkii.upload.maximum_size=32256
avrispmkii.upload.speed=19200
avrispmkii.upload.using=avrispmkii

avrispmkii.bootloader.low_fuses=0xff
avrispmkii.bootloader.high_fuses=0xde
avrispmkii.bootloader.extended_fuses=0x05
avrispmkii.bootloader.path=optiboot
avrispmkii.bootloader.file=optiboot_atmega328.hex
avrispmkii.bootloader.unlock_bits=0x3F
avrispmkii.bootloader.lock_bits=0x0F

avrispmkii.build.mcu=atmega328p
avrispmkii.build.f_cpu=16000000L
avrispmkii.build.core=arduino


##############################################################


Now it shows up in the Arduino software.

Just choose the newly created board, connect your ISP the right way and upload your sketches like you always do :)

Browse to your HIDUINO folder and upload the following example (if you haven't done it already ;)): /Users/phil/Downloads/HIDUINO/Arduino Example Sketches/HIDUINO_MIDI_Example01/HIDUINO_MIDI_Example01.pde

Thats it!! Fire up Ableton Live or any other music program and listen to your Arduino generated notes!! (Don't forget to configure you music program to talk to your device.)

It's my first Instructable and I hope it helped you a bit to get the HID/Midi running :)

In a few weeks I'll show you how to create the hardware for a  4-channel midi controller :)

How to Install Flash on Ubuntu Linux, the easy way!







Step 1: Getting the required stuff

            before doing this please follow This instructable, otherwise this will not work you can find it

ok first you need to go to http://www.adobe.com then click the "get flash" icon on the right hand side of the page. It should automatically detect the fact that you are using Linux and give you the correct file types.

click download, and save to disk the tar.gz file you DON'T want the .rpm or YUM files.

Step 2: Actually installing it

             it won't work yet, go to a website that uses flash, a good example would be www.youtube.com

try and play a video, it won't work thats what we are going to do now, make it work, over the next two steps!


go ahead and open the tar.gz file, and click extract, a new window will pop up, asking you where you want to extract it to, select your desktop (it should select your desktop by itself anyway).

Step 3: Installing it

             actually some of the online tutorials and that I have read make this bit seem really complicated, there is a way to do this using the sudo (super user do) command, but that is quite complex for first time users also if you follow this method rather than the sudo method (which is harder) you will have to do this for every user on you computer (i think.)

anyway, go to the desktop, you will see a folder called the same thing as the tar.gz file you downloaded (something like install_flash_9_linux)

open that folder, you will see that there are two icons in that, click on the FlashPlayer-Installer Icon

now you should get a message, choose "run in terminal" now here is the first time that you are actually going to have to use a command line, and it is really easy!

make sure you read all the instructions as they come up, make sure you have no browsers running, that means Firefox Sea monkey etc.

when you see the "install action summary" press Y (yes) and enter, if you press Q it will give you a load of info about it (boring) or N will not install it (it means no).

let it do its thang, and when it is finished, close it and start firefox, go to youtube and viola

Step 4: After Thoughts

           I believe you can preform a similar procedure to this using Java although I have not installed it (I have no need for it, though obviously getting the required files will be different seeing as it will be from sun micro systems not adobe)

Also although this instructable can help you avoid using Ubuntu's command line (terminal) as much as possible it is a good idea to be able to use it and be relatively competent in its use, because there will be times when you have to use it!

but you will in time get to learn the basic commands such as "sudo apt-get install" etc in time, its all part of the Ubuntu experience (how corny does that sound)

I do read my comments so if this isn't working for you, please use the comments section and I shall endeavor to to help you, (after all it is part of the concept of Ubuntu, remember "I am because you are."

Peace

F1x0r

Brown Sugar Java Fizzie






Step 1: Ingredients

2-2/3 cups water

1 c. coffee beans (or pre-ground coffee), medium to coarse grind
Coffee press or strainer lined with cheesecloth
Whole spices, if desired

Seltzer water
Vanilla extract (optional)

Step 2: Heat water and add ground coffee

           In a saucepan, bring the water to just boiling, and stir in the ground coffee, and spices (if desired).
Remove from heat, and pour into coffee press, or cover and leave on stove top if using a colander to drain (next step).

Step 3: Steeping

             Allow the coffee to steep until cool (up to four hours).

When the coffee has cooled:
For the coffee press, simply push the handle down as far as it will go.  If you're using a cheesecloth-lined colander, Set the colander (strainer) over a bowl, pour the coffee, grounds and all, into the cheesecloth, and bring up the sides of the cheesecloth, forming the coffee grounds into a ball.  Twist and squeeze! 

You should have about 2 cups of insanely strong coffee.

Step 4: "Cooking" the syrup

           The word "cooking" is in quotes, because you really don't want to do much more than heat the brown sugar until it dissolves in the coffee.
If you allow the syrup to boil, you will wind up with a heavy concoction that won't dissolve smoothly in the seltzer.  It  might work for an ice cream topping, but......HEY!  There's your second batch!

In the saucepan, combine the brown sugar and coffee over medium-low heat, and stir until the sugar is dissolved -- usually right around the time the mixture is thoroughly heated (too hot to touch), but not boiling.
Remove from the heat and allow to cool.   If you see a thin, foamy layer on top, just stir it right back in.

Adding 1 teaspoon of vanilla is optional, but it's a very nice touch.
Store in the fridge -- the syrup should keep well for at least several weeks.

Step 5: Finishing

             Make sure your seltzer is very cold.  If possible, have the syrup chilled as well.

Measure out an ounce or two of syrup.

Fill your glass halfway with seltzer, and then very, very slowwwwwwly, begin to pour the syrup into the glass.  If the seltzer foams up, just pause and wait until everything settles, stir gently, and then continue adding.  Taste-test intermittently.  Keep track of how much syrup you add, so you'll be able to establish your preferred ratio of seltzer to syrup.

It's Brunchtime!

Enabling non free software on Ubuntu 7.10 (real quick and easy)







Step 1: The one and only step to doing this

             look at the top of the screen,

choose system, go to administration and click on "software sources"

Ubuntu will ask you for your password so enter it. Make sure no one including the government is looking over your shoulder. *Puts on tin foil hat*

ok now it will open a program with some check box options, check them all, this will allow you to use all repositories, including the restricted and multiverse repositories.

done.

Integrate Ardublock with Arduino IDE







Step 1: Install Arduino IDE

          Download any version of Arduino IDE (here i'm using ver1.0.5) and install it on computer (executable arduino installer is available,so you no need to unzip and copying files)

You can find a desktop shortcut as "Arduino"

Step 2: Download Ardublock

Use this link to download  ardublock-all.jar

http://download1us.softpedia.com/dl/6200a2d98a8df7e8fcd3c120668daa45/51c06f70/100229541/software/programming/ardublock-all-20130607.jar

Rename ardublock-all-20130607.jar to ardublock-all.jar and copy this file.

Step 3: Integrate

1.Now open "My documents" and create new folder as "Arduino".


2.Open "Arduino" folder and create new folder as "tools".
 

3.Open "tools"  folder and create new folder as "ArduBlockTool".
 

4. Open "ArduBlockTool" folder and create new folder as "tool".
 

5.Open "tool" and paste "ardublock-all.jar" here.

 

Step 4: Change sketchbook location

           Now open Arduino IDE and press ctrl+,(comma) then a prereferences window will open here you will find Sketchbook location and change sketchbook location to E:\Documents\Arduino\tools\ArduBlockTool\tool\ardublock-all.jar then press "OK".

Note: Location is deponds upon where you have ardublock-all.jar

Step 5: Restart Arduino IDE and Done

            Now you can find Ardublock under tool menu Tool>Ardublock  and click it.

Step 6: Start Programming in GUI

             Done!!!!!!!!!!!!!!!

Time Lapse Photography - the lazy way!




Step 1: What you will need

Hardware:

Old Java (MIDP 2.0) compatible phone
Some sort of datacable for the phone
Phone carrycase

Software:

J2ME Development kit
FAR manager (optional - depends on state of phone)

Step 2: Write the software

            This is the hard part, believe it or not, there isnt any java based software that does this for phones. There are a couple of python based ones that will work on a Nokia phone, but not my nokia phone :/

I've attached the java files here, I'm NOT attaching the compiled versions though. If you're clever enough to compile/package these then you're clever enough to fix things if they dont work :p

Basically, it presents a menu where you can set the name of the image-set and the timelapse duration. It then spawns a timer that takes photo's and saves them on the memory card.

These are written with the SonyEricson W800 in mind. They should work with any midp2.0 compatible phone though

Step 3: (Optional) hack phone firmware to be less annoying

All apps that access the phone camera and memory must have permission to do so, otherwise they ask for it. Everytime.

Yes, that gets annoying so..

To fix this you have to "sign" the application, which costs money. Not interested! A cunning workaround is to hack the phones firmware to not prompt. Thats done with the FAR manager software and associated plugins

For the W800, the patches are here. They can ruin your phone if you dont pay attention. I'm not supplying instructions here, I dont want hundreds of "Lol I bricked my phone fix it plzzzz kthxbye" comments

My phone now no longer asks me for permission to run the software 

 Step 4: Use it!

            Start the software up, on my phone its in the file manager, then "Games" (because of the rubbish transfer software)
Set the duration (I've chosen 60 seconds here)
Set the name (new, because I'm too lazy to type them)

Hit the "more->go" button and put the camera in the case. Wear it!

Step 5: A test!

                heres the first test, a standard time lapse clock gif :)

I did wear this on my bag whilst wandering to the shop, sure enough I'd left the lens cap shut. I'm planning some sort of strap to attach it to my bag strap and point forward. The pictures are about 30kb each and the camera has a 512mb memory card, so thats about 17000 pictures before it fills up. At 15 second durations thats about 70 hours worth of clips.


So I might just leave this on all day and see what happens :)

JAVA - Introduction




Step 1: JAVA - Getting the tools

            Now, as you probably know, we need some tools to start writing JAVA code. You could just use your notepad, and execute it from the command line, but we will get an editor, because it is easier and faster. We will get the eclpise JAVA editor. (IF HAVING TROUBLE COMMENT)

STEP #1) Go to the website here and click the green download button

STEP #2) Save it to your desktop and click "OK"

STEP #3) When it finishes downloading, right click the file and select "Extract all"

STEP #4) You should see a new folder appear on your desktop, and make sure it has the file "eclipse.exe" in it.

Now double click on the eclipse.exe file with the icon of a solar eclipse. It will ask you to create a workspace when it opens. Enter "myWork" in the name bar, and click OK. You should then see a welcome screen, and in the top right corner click the "workbench" button.Now you should see something like the 1st image at the bottom.
 After that click "File" > "New" > "Java Project".
In the name box, type "myProj", and click next, and then finish. Now, in the project explorer(left of screen) you should see a folder called "myProj". The project explorer is where you can see all of your files.The area in the middle is the mainstage(coding section) and the right part is the Library, which gives us a list of functions and classes.(Will talk about classes and functions later). The bottom part is the error list, if we have any run-time or code problems, they will be there. It is also the console window where output is displayed.
 Finaly, right-click the "myProj" folder we created and go to "New" > "Class". In the name bar type "myFirst". Click finish. You should see the 2nd picture at the bottom for a closer look.

 Now you are ready to start writing code in JAVA. In the next step we will write your first program, and discuss some JAVA elements.

Step 2: JAVA - Getting to work with JAVA

             In JAVA, everything is based on classes, sections of code with commands to execute. There are also these things called methods,smaller sections of code that contain functions too.Usually there are multiple methods in a class,that interact with each other based on values of certain variables and return a value. Those methods are packed into a class, and then classes with methods can interact with other classes and print the return value on the screen. There is
also something called a main method, the method the compiler searches for first. Based on the instructions the main method gives, the compiler can move to different classes to execute different methods,or just stay in the main method.
 For now lets just create a main method. In your "myFirst" class type the code in bold:

public class myFirst {
  
     public static void main(String[] args)
     {
  
     }

}


Now lets discuss this code. Each method is based on the following syntax:

[accessSpecifier] [returnType] [methodName] ( [parameters] )
{
  [methodBody]
}

The access specifiers in this case are "public" and "static". Any method can be "public" or "private". "Public" means the method can be accessed by any class. "Private" means that the method can be accessed by only the class it belongs to. I will explain the "Static" key word later.Here we made a public static main method with the name main, and parameters of "String[] args"(I won't explain the parameters now). In the method body we type all of the commands we wan't to execute. The method body's and class body's are always located between the curly braces.
 NOTE: JAVA is a case sensitive language, so when you type commands, you must type them exactly as specified, or you will get an error!!!!!!
 Now type the code in bold into your main method:


public class myFirst {
  
     public static void main(String[] args)
     {
          System.out.println("Hello world!");
     }

}

By now you should have the code in the 1st picture. Now go to "Run" > "Run", and click "OK" when the dialog box appears, and at the bottom(console window) you should see the text "Hello world!" printed. Check the second image for reference.
 Here we used the command System.out.println to print a line on the screen. The "System", is a class containing many functions. The "out" was that we wanted to print OUT to the screen(or output) and the method "println" means; print line. Then in brackets, and in quotation marks(because this is a string value(value containing words)) we included the text we wanted to print,and ended the line with a semi-colon(;). NOTE: All lines in JAVA must end in semi-colons, except lines when we declare classes or methods. We can also use "print", but the difference between "print" and "println" is that "print" prints text on a line, but "println" means to print the text, and end the line, meaning that if the next command is "print", the text will be printed on a new line.
 At this point, I would like to apologize for the bad quality of my images.I have included some SELF-CHECK questions at the bottom. In the next step I will include the answers to them.In the next step I will also introduce you to the basic value types.



 SELF-CHECK:

 #1)   Write a program to print the word "cheese" letter by letter.

  HINT: Use the "print" command

#2) Use the "print" and "println" commands to experiment.

#3) What is wrong with this line of code:

     System.out.println(Hello world!);
#4) What will you get if you run these lines of code:

    System.out.print("h");
    System.out.print("i");
    System.out.println("per-");
    System.out.print("son");

Step 3: JAVA - Basic Variable Types

             The answers to the previous SELF-CHECK questions are:

#1)      System.out.print("c");
            System.out.print("h");
            System.out.print("e");
            System.out.print("e");
            System.out.print("s");
            System.out.print("e");
#2) No definite answer.

#3) The text in brackets was not in quotation marks.

#4) hi per-
       son

There will also be self check questions at the end of this step.

 There are many data types. In this instructable we will go over only the basic ones, and it will still take a couple of steps.



All variables work on the syntax below.

[dataType] [variableName] = [value];

ex.

  int myNum = 8;

int type:

   
The "int" type, means integer. Works on the same syntax as above. There are no quotes needed to hold the value for any numerical type. Any int variables range from a minimum of -2,147,483,648 to a maximum value of 2,147,483,647. Most common integers will fit in this range, but if they don't use "long" instead.

 ex.

 int nine = 9;

long type:

 
 The "long" type is a long version of the "int" command. Ranges from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.

float type:

  The "float" type is a floating-point number, which means it contains a decimal value.

double type:

 
The "double" type is a floating-point number, which can hold a bigger value.

string type:

 
  The "string" type holds a text value. The text(value) must be inclosed in double quotes.

   ex.
 
       String greeting = "Hi blank";

 
Those were the basic data types. To print any of them just write the variable name in the parameters of the "println" method without quotes.

 ex.
 
    int myNum = 52930;
    System.out.println(myNum + "Is the value of myNum");
The code above would print "52930 Is the value of myNum" on the screen. And by the way we used there a plus sign to combine a String to the line we were printing, so it would print a String value after the value of myNum. You can use the plus sign to add variables in the "println" command and add string values. Check out the two pictures at the bottom to see what I did.

This is section 1/2 of the number types, in the next section I will teach you some simple mathematical operators you can use on the variables.

Step 4: JAVA - Mathematical Operators

       This is section 2/2 of "Basic variable types". Here I will introduce mathematical operators. There is the "+" sign which means addition. It is used for adding numbers.

 ex.

 int sum = 5 + 579;

It is also used to combine strings in the "println" method.

 ex.

 System.out.println("This is " + "three strings " + "combined.");

Notice that before adding another string on the first and second strings I used a space at the end to make it look normal.

There is also the "-" sign as you have guessed, and it is used only to subtract numbers.

 ex.

 int subtraction = 9 - 6;

 Also there is the multiplication operator, which is represented by a "*" in java(asterisk). It is used to multiply numbers.

 ex.

  int multiplication = 756 * 15;

And there is the division operator, which is represented by the "/"(slash). It is used to divide numbers.

 ex.

 int division = 50 / 5



Also there is a modulo operator, which is represented by the "%". Modulo is used to focus on the remainder of two numbers, if there is any.

 ex.

 int modulo = 10 % 9;


You do not need to add quotes for the numbers if you use the numbers in the "println" method, or they will be interpreted as string values.

ex.

 System.out.println(6 + 7);

 COMMON ERROR 1:

 System.out.println("6" + "7" );

  The code above returns 67, not 13. To avoid this delete the quotes.


 The variable names can be used to identify values. Such as:

 int myNum = 9;
System.out.println("The value of myNum  is " + myNum);

 As long as "myNum" doesn't have  any variables around it, the program will print "The value of myNum is 9".  You can also use the operators to perform operations in the "println" method to return quick results.

 ex.

 System.out.println(8 * 10);

My pictures will be basicly on everything we covered in this section, but don't forget to check them out. In the next step there will be little new material, but there will be a test that covers everything we learned so far.  Here are the self check questions:

 SELF-CHECK #1:

  Write a program to calculate the modulo of 789 to 2, and print the result on the screen.

 SELF-CHECK #2:

 Describe the "int" data type, with at least the basic characteristic.

 SELF-CHECK #3:

 Create a string variable called "greeting" with a friendly message in it leaving out the name(ex. Hello _______). Then create a string called "name" with the value of your name. Then combine these variables and you should get your final message.

 SELF-CHECK #4:

 How do you represent multiplication in JAVA?(What sign do you use)

Step 5: JAVA - 1st Test / Commenting

             Here are the answer to the previous SELF-CHECK questions:

#1) System.out.println(789 % 2);

#2) The "int" data type holds an integer.

#3) String greeting = "Hello ";
       String name = "JAVA Teacher"
       System.out.println(greeting + name);


#4) You use an "*"(asterisk)

 OK, now for this instructable I will only include a little new material, and the link to my test.

 In JAVA there is something called "commenting". That means to comment your work.
 There are 2 types of comments you can make a single-line comment(see ex. 1) and a multi-line comment(see ex. 2) . The examples for these comments are included. For a single-line comment you have to put 2 slashes before the text, everything to the right of the slashes is considered a comment, and ignored by the JAVA compiler. A simple multi-line comment is in between the slash and 2 asterisks, and ends with the asterisk and a slash. An advanced multi-line comment discribes a method, we will go over this later.

 JAVA ADVICE:


  I suggest you to comment everything, even the simplest things. Because if someone is going through your work and may have trouble understanding your code. It might not be obvious that the variable d stands for dollars . And I also suggest you to save your work frequently.(I lost a lot of code because of this once)


 ex. 1
 
 int num2 = 78; //Create an integer, "num2" with the value of 78

 ex. 2

 /**
     Create an integer, "num2" with the
     value of 78

    */
  int num2 = 78;

OK, good luck on the test. :-)  (LINK AT BOTTOM, READ NOTE)

NOTE:

 I really rushed through making the quiz, so on #2 I marked the wrong answer as right. The correct answer for that one was the last option. I am very sorry for this inconvenience.



The link to the test is here. There's a picture at the bottom of the welcome screen of the test too.Good luck and don't forget to read my next tutorial! :-)

Programing with Java using Command Prompt







Step 1: Download latest JDK

               1.Follow this link: http://www.oracle.com/technetwork/java/javase/downloads/index.html
2. Click Download JDK under the download Java Standard Edition panel.
3. Choose your operating System and agree to the terms of service. **
** This will  probably be Windows since your using Command Prompt.

Step 2: Setting Path for Command Prompt

1. Open the Command Prompt .
2 Type "set Path=C:\Program Files\Java\jdk1.6.0_21\bin" .*
3. Type  " set HomePath= C:\Program Files\Java\ jdk1.6.0_21 *

* If you have a later jdk ( i.e. jdk 1.6.0_22) replace the portion that says jdk1.6.0_21 with it.

** If you don't know which jdk you have go to: start pane( at bottom left corner of you screen)>click run> click browse>Then  go to C:\Program Files\Java

*** Do not type quotation marks in steps 1-3  at command prompt.

Step 3: Creating a Simple Java Program

Create Program
1. Go to Start pane>All Programs > Accessories> Notepad.exe
2 Copy and paste the following exactly:
public class helloworld
{
public static void main(String[] args)
{

System.out.println("Hello World!");

}
}
3. a.Save file as: helloworld.java
     b.Make sure "save as type" under where you typed the file name as "All Files" (as opposed to the default "Text-File").
      c. You want to save your java file where  the Command Prompt  is set to open at.*

*Such as C:\Users\MyUserName

Step 4: Compiling and Executing the Program

          1.First compile file by going to Command Prompt and typing javac  helloworld.java
2.This will create a class file which you can execute by typing java helloworld
3. It should print "Hello World!" to show your done.

Step 5: Learn More

             1. The next thing you want to do is get a textbook that will teach you the Java language, precisely.I recommend Programing and Problem Solving with Java
 by Nell B. Dale and  Chip Weems .
2. You can get this from Amazon.com following this link:
http://www.amazon.com/Programming-Problem-Solving-Java-Weems/dp/0763734020/ref=sr_1_2?ie=UTF8&qid=1291909285&sr=8-2

Using Blender To Create Java3D Models







Step 1: Download The Programs

    You will need Blender (http://blender.org) and Blend2Java (http://sourceforge.net/projects/blend2java/). Ok then once you have them both start off by making a simple model (or just using the standard cube) in Blender.

Step 2: Export Your Model To XML

            Once you have a model you would like to use in Blender open Edit Mode and hit the "a" key to select all points. In the bottom panel select text editor.

Open a new file in the text editor. Open the blend2java.py file that you downloaded. Run.
Ok your object should now be in .XML wherever you saved it (if you have and error message make shure you only have 1 material for the object). Rename the object (it will have a weird name).

Step 3: Import The Object To Java

Shape3D fred = null;
try {
XMLDecoder e = new XMLDecoder(new BufferedInputStream(new FileInputStream("c:/HandShape3D.xml"))); //your file name here
fred = (Shape3D) e.readObject();
e.close();
} catch(Exception e) {
e.printStackTrace();
}

ColoringAttributes at=new ColoringAttributes();
Appearance ap = new Appearance();
Color3f col = new Color3f(1.0f, 0.0f, 1.0f);
ColoringAttributes ca = new ColoringAttributes(col, ColoringAttributes.NICEST);
ap.setColoringAttributes(ca);
fred.setAppearance(ap);
obj.addChild(fred);

insert this into any 3d code or use the whole code here

import java.io.*;
import java.beans.XMLDecoder;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.universe.*;
import javax.media.j3d.*;
import javax.vecmath.*;

import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.Frame;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.geometry.ColorCube;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.behaviors.mouse.*;
import javax.media.j3d.*;
import javax.vecmath.*;
import java.awt.event.*;
import java.util.Enumeration;

public class MouseBehaviorApp extends Applet {

public BranchGroup createSceneGraph() {
BranchGroup objRoot = new BranchGroup();
TransformGroup objTransform = new TransformGroup();
objTransform.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
objTransform.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);

objRoot.addChild(objTransform);
Shape3D fred = null;
try {
XMLDecoder e = new XMLDecoder(new BufferedInputStream(new FileInputStream("c:/HandShape3D.xml")));
fred = (Shape3D) e.readObject();
e.close();
} catch(Exception e) {
e.printStackTrace();
}

ColoringAttributes at=new ColoringAttributes();
Appearance ap = new Appearance();
Color3f col = new Color3f(1.0f, 0.0f, 1.0f);
ColoringAttributes ca = new ColoringAttributes(col, ColoringAttributes.NICEST);
ap.setColoringAttributes(ca);
fred.setAppearance(ap);
objTransform.addChild(fred);

MouseRotate myMouseRotate = new MouseRotate();
myMouseRotate.setTransformGroup(objTransform);
myMouseRotate.setSchedulingBounds(new BoundingSphere());
objRoot.addChild(myMouseRotate);

MouseTranslate myMouseTranslate = new MouseTranslate();
myMouseTranslate.setTransformGroup(objTransform);
myMouseTranslate.setSchedulingBounds(new BoundingSphere());
objRoot.addChild(myMouseTranslate);

MouseZoom myMouseZoom = new MouseZoom();
myMouseZoom.setTransformGroup(objTransform);
myMouseZoom.setSchedulingBounds(new BoundingSphere());
objRoot.addChild(myMouseZoom);

objRoot.compile();

return objRoot;
}

public MouseBehaviorApp() {
setLayout(new BorderLayout());
Canvas3D canvas3D = new Canvas3D(SimpleUniverse.getPreferredConfiguration());
add("Center", canvas3D);
BranchGroup scene = createSceneGraph();
SimpleUniverse simpleU = new SimpleUniverse(canvas3D);
simpleU.getViewingPlatform().setNominalViewingTransform();
simpleU.addBranchGraph(scene);
}

public static void main(String[] args) {
Frame frame = new MainFrame(new MouseBehaviorApp(), 256, 256);
}
}

use this for a complete program

tada! you are done!
and then you say "now what"?
I have no idea! I just learned Java a month ago lol!

How To Play Java[ME] Games On A PSP!





Step 1: What Ya Will Be Usin'!

             Hardware: A Psp ( custom firmware ONLY )
A PC
A PSP usb cable

Software: PSPKVM (http://www.pspkvm.com/(Click On Downloads)
Optional: Java Games (http://www.getjar.com/software/Sony-Ericsson/W850i)
Opera Mini (http://www.getjar.com/products/3334/OperaMiniWebbrowser)

Get these things before you continue...

Step 2: Install PSPKVM

              Copy "PSPKVM" to /PSP/GAME or /PSP/GAME150 or /PSP/GAME5XX folder.


Depending on what firmware you have or just try each of them and see if they work.


Heres A Video: http://tinypic.com/player.php?v=2vcj9s2&s=5

Step 3: Using PSPKVM!

             Put The java games in a folder of your PSP ( like: Java Games + Apps )!


Then:


  • Run PSPKVM on your PSP

  • Click Find Applications (By Pressing Start)

  • Then Click Install from memory stick ( by pressing start )

  • Then Go into whatever folder your java files are in ( press O )

  • Then press your java game/app ( by pressing start )

  • Then click J2ME standard (480*272) ( by pressing O )

    Step 4: Before you try to use anything!

  • Exit The Application ( if you are on one ) and :1-Start PSPVKM

2-Go to network set up. Press start to launch

3- click your network name. Press start

4- wait for it to finish and click done. Press start

5-Press Select to go back to the main page

6- Start opera mini!


Note : Your network needs to be configured on your PSP before you do it.

Step 5: And Thats It!

Yay You've done it! Please comment!

Setup Java for Beginners







Step 1: Download the Software

              (Only Windows) You will need to install, "Java SDK"(Java source code) and "Crimson Editor"(Color Text Editor). Links below.

Java SDK
 Download the latest release of the Java SDK or JDK (means the same thing) from http://java.sun.com. You will get an install program named something like j2sdk-1_4_1_05-windows-i586.exe, run this program and it will install the Java Software Developers kit. (make sure the file is called j2sdk####, and not j2jre#### which is the Java Runtime Environment).

Crimson Editor
Download the latest release of crimson editor from http://www.crimsoneditor.com. You will get an install program named something like cedt.exe, run this program and it will install crimson editor on your system.

 

Step 2: Installing Java and Crimson Editor

              Java
Now, after downloading Java SDK. Click on the exe that you have downloaded to start the install process. You should just click next when prompted or until it has finished installing. and remember where you are placing the install files such as the to the default location, "C:\SunSDK"

When you create the admin account name and password please note it down or something will not work for you later in your java programming experience.

Crimson Editor

After Crimson Editor download has finished.Click on the exe that you have downloaded to start the install process. You should just click next when prompted or until it has finished installing. 

Step 3: Configure Crimson Editor to compile and run Java programs

              Set up “compile java” menu option

Start Crimson editor (you may get an error the first time you start it, ignore the error) Click on the tools menu, then conf. user tools (or something close to that) You should see a dialog with a list of items that say “empty” select the first empty item in the list. For menu text enter “compile java  where it says command enter the path your javac.exe is found. That will be where you installed the java JDK\bin\ followed by javac.exe (example: C:\Sun\SDK\jdk\bin\javac.exe). Where it says argument click the black arrow to the right and select File Name, this should enter $(FileName) for you in the text box. Where it says initial directory click the black arrow to the right and select File Directory which should enter $(FileDir) in the text box for you. At the bottom make sure the checkbox that says “capture output” is checked. This preserves any error messages generated by the Java compiler. If you click OK and then go to the tools menu again, you should now see an option for compiling java programs.

 Set up “run java” menu option

Click on the tools menu, then conf. user tools  You should see a dialog with a list of items that say “empty” select the first empty item in the list. For menu text enter run java where it says command enter the path you found above followed by java.exe (example: C:\Sun\SDK\jdk\bin\java.exe). Where it says argument click the black arrow to the right and select File Title, this should enter $(FileTitle) for you in the text box. Where it says initial directory click the black arrow to the right and select File Directory which should enter $(FileDir) in the text box for you. At the bottom make sure the checkbox that says “capture output” is NOT checked. Also, make sure the checkbox that says “close on exit” is NOT checked. If you click OK and then go to the tools menu again, you should now see an option for running java programs.

Step 4: Testing Java

Java 101 : Hello World


1 Save the file as what your class is called but with a .java so something like this, "myfirstjavaprog.java.


2. Go to compile that we just created.


3 now go to RunNOW that we created and look at the output. and you should be done.


CODE:

class myfirstjavaprog

        public static void main(String args[])

        {

           System.out.println("Hello World!");

        }

Step 5: Learn Java

           You now have setup java to create anything you want in the world. and you created your first program what next anything. programing is an Art form like any other media all you have to be is creative. let me know if you find anything wrong with my setup.

Step 6: Set up your environment. (optional)

              If you are running Windows XP or higher skip these steps please. :)

Windows 98 Find the location of your java/bin directory

If you click on the Start menu, then Find, then Files or Folders, and type javac.exe where it says “Named:” This will locate any file on your computer named javac.exe, once the file is located, to the left you should see the name of the folder where your Java compiler, and Java runtime environment is contained. It should be something like c:\j2sdk1.4.1\bin

 Tell DOS how to find your Java SDK

Run notepad, and then open the file “c:\autoexec.bat” if this file doesn’t already exist, create it.

Make a new line at the end of this file and add

SET CLASSPATH=%CLASSPATH%;.

Add another line and type

SET PATH=%PATH%;c:\j2sdk1.4.1\bin

But replace c:\j2sdk1.4.1\bin with the path to your java/bin directory that we found in the previous step.

 Tell DOS to execute autoexec.bat whenever you start the command prompt

Start a command prompt, either by clicking on it’s icon in the Start menu, or by clicking the Start menu, then the Run… item and then typing “command” and pressing enter. If your entire screen turns black and you only see text, this means you are in full-screen mode, just press alt-enter at the same time and you will be back in windows mode. While in windows mode you should see an icon at the top of your DOS window that looks like a hand pointing at a piece of paper. Click on this icon and a dialog will appear with several places to enter information. Where it says batch file type c:\autoexec.bat Then click on the tab that says “memory” and set the initial environment to a high value like 4096.

How to make a HelloWorld application in Java Netbeans




Step 1: Downloading

             If you haven't yet, you will need to download and install the latest version of Java Netbeans. If you have you can skip this step. Click to run it and save it somewhere safe, like your installs folder.

Step 2: Getting Started

             Open it up and create a new project and name it HelloWorld. We will use the rest of the default settings..

Step 3: Coding

       Once it opens click underneath where it says public static void main(String[] args)  { click on the end of the notes, (the text in green)  hit return and type: System.out.println("Hello World!"); It is very important that you type this exactly, you can even copy and paste it if you want to.

Step 4: Explanation

          So basically what we just did was tell the system to print out "Hello World!" the ln after print is what keeps the text on separate lines, try taking out the ln and see what I mean. If you haven't yet, run your application and watch the magic unfold before your eyes. You can change the text "hello world!" to something else like "I love pancakes!" or "Go instructables! Really anything you want you can type there, I hope you liked this instructable and will check out my others, please leave a comment and tell me what you think! bye!

Programming Java for Absolute Beginners




Step 1: Downloading the Tools

          First go here and download "java netbeans" it is the IDE we will be using. IDE stands for Integrated Development Environment, meaning it is the program where you will do all your coding. Once you've downloaded and installed it, open it up.

Step 2: Understanding the IDE

           When Netbeans opens you will be greeted by the IDE. Now, I know it may seem like a lot to take in, but let me break it down.
At the top of the screen you should see many different icons, the first is "New File" You can use this to create classes and other files, but we will get into this more later. The second icon you will probably use the most, this is the "New Project" icon. The next icon is the "Open Project" icon. You can use this if you made an application on a different computer, and want to open it on a different computer. The next is "Save All", in Java Netbeans you can have multiple projects open at one time, and this allows you to save them all at once. Next is "Undo" and "Redo", they are pretty self-explanatory. The next five are "Build" which compiles your project so you can create an executable of it (A distributable file). Next is "Clean and Build" This cleans all the files in your project. After that is "Run" use this to Run your projects code. Those are the only icons you really need to know. On the right you should see a projects tab, this is where you can access the files of all your applications. Now, that you understand a little more about this IDE, let's get started making this application!

Step 3: Building your Application

        Let's start with a very simple application, the famous Hello World application will do. Now, what we are going to do is have the computer say "Hello World!". To do this create a new project, Click "Next", and call the Project "HelloWorld", leave everything else default and click "Finish". Now, You should be greeted with this code:

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package helloworld;

/**
*
* @author Your name here
*/
public class HelloWorld {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
    }
}



Highlight "// TODO code application logic here" and type System.out.println("Hello World!");

Now, I'm going to explain what we just did. We just told the system to print out "Hello World!" ln means line, so it will print all the words on the same line, try taking it out and see what happens! If you want some more advanced techniques try typing "sout" and press the tab key.

Step 4: Wrapping Up

           I really hope you enjoyed this instructable and took something away from it. Please leave some feedback below if you enjoyed, I really appreciate it! Feel free to check out my other projects if you would like to know a little bit more advanced code. If you would like to see more, just leave a comment. Have a nice day!

Java (Programming Language) For Beginners


Step 1: What Is java?

          Java is just one of the hundreds of different programming languages in the world. Java language is an object-orientated programming language which was developed by Sun Microsystems. Java programmes are platform independent which means they can be run on any operating system with any type of processor as long as the Java interpreter is available on that system.

Step 2: What You Will Need

            You will need the Java Software Development Kit from Sun's Java site. Follow the instructions on Sun's website to install it. Make sure that you add the java bin directory to your PATH environment variable. To find the Java Software Development Kit, go to the top right-hand corner of the screen and you will see a search bar. Type in: Java Software Development Kit. The the search results appear, find the one that says something along the lines of download.

Step 3: Writing Your First Java Programme:Part 1

              You will need to write your Java programs using a text editor. When you type the examples that follow you must make sure that you use capital and small letters in the right places because Java is case sensitive. The first line you must type is:

public class Hello

This creates a class called Hello. All class names must start with a capital letter. The main part of the program must go between curly brackets after the class declaration. The curly brackets are used to group together everything inside them.

public class Hello
{

}

Step 4: Writing Your First Java Programme:Part 2

              We must now create the main method which is the section that a program starts.

public class Hello
{
public static void main(String[] args)
{

}
}

You will see that the main method code has been moved over a few spaces from the left. This is called indentation and is used to make a program easier to read and understand.

Here is how you print the words Hello World on the screen:

public class Hello
{
public static void main(String[] args)
{
System.out.println("Hello World");
}

Step 5: Writing Your First Java Programme:Part 3

             Make sure that you use a capital S in System because it is the name of a class. println is a method that prints the words that you put between the brackets after it on the screen. When you work with letters like in Hello World you must always put them between quotes. The semi-colon is used to show that it is the end of your line of code. You must put semi-colons after every line like this.

Step 6: Compiling The Programme

              What we have just finished typing is called the source code. You must save the source code with the file name Hello.java before you can compile it. The file name must always be the same as the class name.

Make sure you have a command prompt open and then enter the following:

javac Hello.java

If you did everything right then you will see no errors messages and your program will be compiled. If you get errors then go through this lesson again and see where your mistake is.

Step 7: Running The Programme

           Once your program has been compiled you will get a file called Hello.class. This is not like normal programs that you just type the name to run but it is actually a file containing the Java bytecode that is run by the Java interpreter. To run your program with the Java interpeter use the following command:

java Hello

Do not add .class on to the end of Hello. You will now see the following output on the screen:

Hello World

Congratulations! You have just made your first Java program.