<< The Code >>
; THE GAME OF SHAME
; CRICKET 1
global: avg first last
to runcricket1
forever [cric1]
end
to cric1
if touching?c [questionasking1]
if touching?d [questionasking2]
end
to questionasking1
average-gsra
storeinfirst avg
wait 30
chirp
chirp
chirp
wait 50
average-gsra
storeinlast avg
beamir first - last
end
to questionasking2
average-gsrb
storeinfirst avg
wait 30
chirp
chirp
chirp
wait 50
average-gsrb
storeinlast avg
beamir first - last
end
to average-gsra
storeinavg gsra
repeat 19 [wait 1 storeinavg (gsra + avg)]
storeinavg (avg / 20) ;this is an average of 10 resistances done within one
second
end
to average-gsrb
storeinavg gsrb
repeat 19 [wait 1 storeinavg (gsrb + avg)]
storeinavg (avg / 20) ;this is an average of 10 resistances done within one
second
end
to gsra
rawrangea 2
output rawresistancea - 24
end
to gsrb
rawrangeb 2
output rawresistanceb - 24
end
; THE FOLLOWING PROGRAM IS ONLY FOR CRICKET 2
global: message counter threshold diff
to runcricket2
forever [cric2]
end
to cric2
if newIR? [rotator]
end
to rotator
storeindiff ir
displaya diff
displayb diff
end
For the exhibition, our code ended here as we could not initiate shaft-decoder without crashing Cricket Two. The above procedure enabled us to beam the GSR value to Cricket Two to be displayed on the numerical displays but forced us to control the rotating display manually. The initial code that we had planned on using would automate the manual process by sorting the GSR values according to a set of predetermined ranges and rotate the display to its respective message using the shaft-decoder. This initial code is set out below:
to cric2
if newIR? [storeindiff ir displaya diff displayb diff rotator]
end
to rotator
if diff < 11 [note 65 5 note 55 10 note 40 20]
if ((diff > 10) and (diff < 26)) [storeinmessage 1 rotate]
if ((diff > 25) and (diff < 38)) [storeinmessage 2 rotate]
if diff > 37 [storeinmessage 3 rotate]
to shaft-decoder
repeat message [waituntil [not (brightness > (threshold + 40))]
waituntil [brightness > (threshold + 40)]]
end
to auto-threshold
atoreinthreshold brightness
end
to rotate
auto-threshold
thisway
motoron
shaft-decoder
waituntil [counter = message]
motoroff
wait 100
auto-threshold
thatway
motoron
shaft-decoder
waituntil [counter = message]
end
The reasons why we wanted to tear our hair out..
The sensors posed a slight problem as the electrodes are extremely sensitive to pressure and movement. We attempted to compensate for this overt sensitivity in our programming by taking several readings and finding the average reading over a short period of time. Galvanic skin responses are also largely dependent on individual variables such as skin type, gender and diet, among others. This was dealt with by having our program take an averaged individual baseline reading before the question is asked and comparing that reading with an averaged reading after the question.
We also ran into problems while setting global variables in our program. PicoBlock is only capable of having five global variables while our initial program required eight. Since we had written our entire code before actually running it on our project, we were completely flustered and frustrated for several hours when our seemingly “perfect” code crashed the Crickets every time we attempted to run the program. Finally, with much help from Robbie and Lyn, we discovered the bug in using global variables and decided to separate our program into two parts; one for Cricket One and another for Cricket Two, each with three and four global variables respectively.
A final problem in our program surfaced a mere two hours before the exhibition. The shaft-decoder procedure would not initiate and crashed Cricket Two every time we tried running the program. We knew that each individual procedure was working but when we tried running entire program, the motor would not go on as specified. This problem has not been solved yet.
..and of course, our final attempt at coding
(this time in HandyLogo and with Agnes and Susan):
global: finalgrade
to mygrade
loop[ifelse (finalgrade = A) [print "thankyou"] [setfinalgrade A]
end
:)
*and a plug for Agnes and Susan's robotics website: ducky polo