Lab 2. java fundamentals -- types, variables, constants,
basic program featues: methods, classes, documentation
Lab Work: Note: long variable are not supported by TinyVM.
(although they may be by the time we use it for the
labs/projects). Strings are also not supported. Although
support is coming in leJOS (code fork from TinyVM).
Either can add a motor (not connecting it to anything),
Or use the sound things more. Or just the LCD.
If using the sound thing, define durations, etc with
note lengths (ie whole note, half note, etc). Use
variables to play the same note for different lengths,
then different notes, at the same lenght.
ie.
final int half_note = 15; // not accurate
final int note_A = 135; // not accurate
int tone, duration;
tone = 0;
System.playTone(tone, half_note);
tone = 15;
System.playTone(tone, half_note);
(remember the sleep call needed after eight playings).
...
duration = 1;
System.playTone(note_A, duration);
duration = 15;
System.playTone(note_A, duration);
...
If you use the motor.
The only way to get direct feed back is by how long
the motor is going (motor power is too hard to tell
the difference without tires, direction is set using
forward(), backward() not numbers, unless you want
to use lower-level stuff). This means that different
calls to sleep would be used. I dont think this would
be very helpful for direct feed back.
The last way, is to use the LCD. (One could use the motor
at the same time).
This would be mostly boring, as you just display
numbers on the screen. There isn't good support
for negative numbers, or decimal numbers. Best
support for unsigned integers.
(Might improve).
Projects:
Display text on the LCD. char arrays, or Strings,
if supported, by then.
Simple "scrolling" text: to display text longer
than 5 characters, dislay the first 5, then the
second 5, etc. Using sleep inbetween.
© Copyright 2000 By Joel Adams, Ryan VanderBijl.
Lisenced under the GPL. You may use it, but we would like you to
share any ideas, etc with us and the world.