read out carolling christmas bells


Author Message
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 3321
Posted: 06:31am 03 Nov 2025      

An untested way to read from the solenoids. If it works change the Print line to print to a file.
'Reading the 12 outputs of a chiming bells ornament. (untested)
'It records the time (mS) when each bell is struck and the number of the bell(s)
setpin gp0, din
setpin gp1, din
setpin gp2, din
setpin gp3, din
setpin gp4, din
setpin gp5, din
setpin gp6, din
setpin gp7, din
setpin gp8, din
setpin gp9, din
setpin gp10, din
setpin gp11, din

Dim integer Bells(200,2), n, tmp, tmp2

Timer = 0

for n = 0 to 200 'or whatever the sequence length is
 tmp = Port(gp0,12)
 do while Port(gp0,12) = tmp : loop : tmp2 = Port(gp0,12) 'wait for a chime
 Bells(n,0) = Timer
 Bells(n,1) = tmp2
 Pause 50 'Wait for solenoid pulse to end. Make longer than a solenoid pulse.
  'Needs to be shorter than the shortest interval between chimes
next

for n = 0 to 200
 Print Bells(n,0), Bells(n,1), Bin$(Bells(n,1),12)
next

end

Add solenoids to your xylophone (ok, the notes won't be exactly right but the melody may still be ok) and use the PORT Command to play back the file to the solenoids.
Edited 2025-11-03 16:55 by phil99