;-- roboCOMM.txt -- ; works with a stepper motor and relay coil connected to portb global [position destonation place command speed] to powerup write portb-ddr 0 write portb 0 setposition 39 setdestonation 39 write portb 0 setspeed 12 a 20 end ;-- Subroutines ---------------------------------------------------- to step if not (position and 3) xor 0 [write portb 32] if not (position and 3) xor 1 [write portb 16] if not (position and 3) xor 2 [write portb 64] if not (position and 3) xor 3 [write portb 128] mwait speed write portb 0 end to move-to :place ;step the motor from position to destonation setdestonation :place loop [ if not position - destonation [ print position stop ] ifelse position < destonation [ setposition position + 1 step] [ setposition position - 1 step]] end to beats :n ;beat on something n times repeat :n [ write portb 4 mwait 20 write portb 0 mwait 30 ] end ;--------------- notes --------------------- to a :len move-to 39 beats :len end to b :len move-to 33 beats :len end to c :len move-to 27 beats :len end to d :len move-to 22 beats :len end to e :len move-to 17 beats :len end to f :len move-to 11 beats :len end to g :len move-to 7 beats :len end to h :len move-to 1 beats :len end to w :len ;null note repeat :len [ mwait 50 ] end ;----------- Main ---------------------------------------------------- to startup song end to song a 20 h 20 g 15 e 5 f 5 g 15 h 15 a 20 f 20 e 40 a 20 d 20 c 15 a 5 b 5 c 15 d 15 b 20 a 5 w 1 a 5 b 15 c 20 a 20 e 10 c 5 e 5 c 5 e 5 c 5 e 5 c 5 e 5 d 5 e 5 d 5 e 5 d 5 e 5 d 5 e 5 f 20 w 5 f 25 w 25 e 10 c 5 e 5 c 5 e 5 c 5 e 5 c 5 e 5 f 5 e 5 f 5 e 5 f 5 e 5 f 5 f 5 g 20 w 5 g 25 h 25 f 25 e 25 a 0 end to fin f 5 w 5 g 5 w 5 h 5 w 10 e 10 w 5 d 5 w 5 c 5 w 5 b 5 w 10 a 20 end