Robotics I - Lab 1 Joseph Giardina 1. I worked with 2 sensors for this part of the lab The first sensor I worked with was the Photosensor(analog). The closer my hand was to the sensor the higher the number. The further away my hand was, the lower the number. The second sensor I worked with was the touch sensor (digital). When it wasn't pressed it returned a 0, when it was it returned a 1. The program I used was as follows: global [temp] to detect loop [ settemp switcha //or for analog sensora if temp=0 [output 0] if temp=1 [output 1] ] end I also worked with the motor commands and wrote the following program: to motortest a, onfor 10 wait 30 beep motortest end 2. The commands for ir communication are as follows: ir - retrieves value newir? - waits for value to be received send - transmits value over infrared These are the two programs I used for communications between the two crickets: Cricket 1: to sender send random % 3 beep wait 30 sender end Cricket 2: to doit waituntil [newir?] if ir=0 [a, onfor 10] if ir=1 [beep] ir ir=2 [beep beep] doit end The random number generator seemed sporadic. It seemed to generate the same mod number for 3-4 second spurts at a time. 3. For this question I had no problem accomplishing the task. I made two programs because I only used two crickets. Cricket 1 - initially starts communication: to sender send 1 a, onfor 10 waituntil [newir?] if ir = 1 [beep] sender end Cricket 2 - initially waits for IR signal to doit waituntil [newir?] if ir = 1 [beep] send 1 a, onfor 10 doit end If there were more than two crickets, there would have to be a time delay after the send command so that there would be time to turn the cricketboard around so that the infrared communicators would be facing each other. Also, only one cricket's program would look like Cricket 1's program. All other programs would look like cricket 2's 4. I figured out that the array starts at index zero. My program is as follows: array [clicks 10] to blah aset clicks 0 0 //this was to make sure the value gets initialized db 0x000 1 //db 0x001 1 could have optionally been used to set low end bit send aget clicks 0 // send value to display center on computer wait 1000 end The value returned when high-bit was set was 256 The value returned when low-bit was set was 1 This could only happen if the array starts at zero index. This is because according to the way memory is set up, 0x000 is the high-byte of the first value in the array. 5. Here is the program I put on the cricket to continually send data: to datasend loop [send sensora] end I used code from a previous semester's student for the basic port commands. The two programs are shown with the attached code. What I added was the display part of the code. It just uses simple printf statements. This gave a horizontal bar reading that was designed with a photosensor in mind. The program prints out from 0 to 25 consecutive '-' characters depending on whether the light value (0 to 255) 25 consecutive bars (e.g. "-------------------------") indicates max light 15 consecutive bars (e.g. "---------------") indicates relatively average light 5 consecutive bars (e.g. "-----") indicates relatively low light The general concept is that the more bars appear, the more light the photosensor "sees" and vice-versa. An example printout would be: ------------------------ (at time 8) (photosensor getting max light) ---------------------- ------------------- ------------- --------- ------- ----- --- (at time 1) (light almost all covered up initally) The photosensor is more and more exposed to light as time progresses in this example.