﻿ GLAZUNOV: Explanation

# GLAZUNOV: Explanation

### Explanation

Glazunov runs on one motor and 11 sensors, all hooked up to a single rather overworked Handy Board, along with a computer to output the notes.

The motor starts off the motion of several chain links interconnected by gears, thereby leading a sheet of paper through the machine, under a row of sensors, and out the other side.

As for the sensors, we used reflectance sensors, which are able to differentiate between black and white. Each sensor was programmed to play the appropriate note upon detecting black.

The 11 sensors are hooked to both digital and analog sensor ports. The analog sensors read number ranging from 0 to 255 where as the digital sensors are set to 128. The digital sensors provides two outputs, true (0) and false (1), therefore we have to treat them as if they are switches. The sensors check to see if the switches are turned on before it executes the rest of the code.

The code runs as follows:

```global [black]

setblack 100
; assume reflectance sensor is plugged into sensor 0
loop [
]
end

if (not(switch :sens))
[resett
waituntil [or (switch :sens) (timer > 5000)]
send :pitch
send timer / 100
print timer]
end

to play-music
loop [
make "pitch recc
if (and (:pitch > 49) (:pitch < 99))
[show "pitch= show :pitch
make "dur recc
if (and (:dur > 0) (:dur < 50))
[show "dur= show :dur
note :pitch :dur wait 1]]
]
show "done
end

to recc
loop[
make "x .recc
if :x > -1 [output :x]]
end
```

'to read-paper' is a code that allows the computer to receive information from the Handy Board to play the notes that correspond to each sensor. 'Setblack 100' is the threshold for the sensors. When a sensor reads a number that is greater than 100, it will play the appropriate note. The space in between the sensors and the paper had to be adjusted so that the sensor could read the black electrical tape. When the sensors are too far away from the paper the numbers will read above 100 even before the sensors detect the black electrical tape. Therefore the Handy Board will be confused and not read the notes. In 'to read-paper,' the first number next to read-note represents the sensor and the second number represents the pitch. The range of the pitches are from 50 to 67.

digital input: sensor 14 => Note nubmer: 50 - D
digital input: sensor 13 => Note number: 52 - E
digital input: sensor 11 => Note number: 53 - F
digital input: sensor 10 => Note number: 55 - G
digital input: sensor 8 => Note number: 57 - A