|
Objective
The objective of the lab is to experiment with the Handy Cricket and the Cricket Logo software.
The Handy Cricket
Have utilized the motor and sensor commands with the following code:
to onwait
a, on
waituntil [switchb]
off
end
Have tested the IR communications primitives by having two crickets communicate with each other:
to sender
send random % 3
beep
wait 30
sender
end
to doit
waituntil [newir?]
if ir = 0 [a, onfor 10]
if ir = 1 [b, onfor 10]
if ir = 2 [ab, onfor 10]
doit
end
Issues involved in multi-Cricket applications would have to do with the distance of communication capability and at the
same time trying to limit miscommunications, that is, when cricket 'c' talks to cricket 'a', cricket 'b' does not think its
for him. The second issue I could foresee in having many crickets is that of timing, in sequential messaging one would have
to allow (depending on the application) the message to get through all the crickets before starting a new message. Synchronizing
all the crickets is also of a concern for multi cricket scenarios.
Experimented with the arrays to test the use of 0 and 1 index by utilizing the following code:
array [click 10]
to deter
aset click 1 5
send aget click 0
beep
wait 20
send aget click 1
beep
wait 20
aset click 0 6
send aget click 0
beep
wait 20
send aget click 1
beep
wait 20
end
The use of 0 and 1 array indexes can also be seen by looking at the memory map of the cricket.
Reading and Displaying Sensor Data
The Cricket had a photo sensor connected to its sensor 'a' input and the following code was being run on it:
to take-data
send sensora wait 10
take-data
end
In the mean time the C code retrieves photo sensor data from the cricket and based on the read value enters a number of
asterisks(*) proportional to it on the command line. Each read sensor value takes up a line on the command line. The program
is compiled using the Microsoft Visual C++ application and ran at the DOS prompt. I can't take credit for the C code that
retrieves the serial data, but I did have to fiddle with it to make it do the asterisk display. Sample output is shown below.
C:\Russ\serial_read\Debug>serial com2 9600 decimal newline yes
press Esc or Ctrl+C to terminate
****
****
************
************************************
************************************
************************************
*******************
**********
***********************************
***********************************
**********
*****
*****
*****
****
|