Option Explicit Const UpLip as Byte = 10 'upperlip Const LowLip as Byte = 9 'lowerlip Const ELids as Byte = 11 'eyelid Const Eyes as Byte = 12 'eyes Const UpperCenter as Single = 0.0017 ' Bigger makes it smile Const LowerCenter as Single = 0.0017 ' Bigger Makes it sad Const LidCenter as Single = 0.00175 '.0016 Open .0018 closed Const EyeCenter as Single = 0.0017 ' 19 its left, 14 right Const ServoSleep As Single = 0.015 Const smoothness As Integer = 10 '********************************************************* Sub Fun() Dim x as Byte Dim i as Byte For i=1 to 5 Call MovingEyes Call Delay(0.01) Next Call Normal Call Delay(0.01) Call Squint Call Delay(0.01) Call Surprise2 Call Delay(0.06) Call Normal Call Delay(0.01) Call Smile Call Delay(0.01) For x=1 to 2 Call BrowThing Call Delay(0.01) Next Call Delay(0.03) Call Yawn Call Normal Call Sleeping End Sub '********************************************************* Sub Wow() Dim x as Byte For x=1 to 15 Call PulseOut(ELids, 0.0016, 1) Call Delay(0.01) Next For x=1 to 15 Call PulseOut(UpLip, 0.0012, 1) Call PulseOut(LowLip, 0.0013, 1) Call Delay(0.01) Next For x=1 to 15 Call PulseOut(UpLip, 0.0019, 1) Call PulseOut(LowLip, 0.0015, 1) Call Delay(0.01) Next Call Delay(0.2) For x=1 to 15 Call PulseOut(UpLip, 0.0013, 1) Call PulseOut(LowLip, 0.0014, 1) Call Delay(0.01) Next End Sub '********************************************************* Sub Surprise2() Dim x as Byte For x = 1 to 15 Call PulseOut(UpLip, 0.0019, 1) Call PulseOut(LowLip, 0.0020, 1) Call PulseOut(ELids, 0.0019, 1) Call Delay(0.015) Next End Sub '********************************************************* Sub Angry() Dim x as Byte For x = 1 to 15 Call PulseOut(UpLip, 0.0012, 1) Call PulseOut(LowLip, 0.0018, 1) Call PulseOut(ELids, 0.00165, 1) Call Delay(0.015) Next End Sub '********************************************************* Sub Sleeping() Dim x as Byte For x = 1 to 15 Call PulseOut(UpLip, 0.0015, 1) Call PulseOut(LowLip, 0.0015, 1) Call PulseOut(ELids, 0.0013, 1) Call Delay(0.015) Next End Sub '********************************************************* Sub Yawn() Dim x as Byte For x = 1 to 15 Call PulseOut(UpLip, 0.0012, 1) Call PulseOut(LowLip, 0.0013, 1) Call PulseOut(ELids, 0.0016, 1) Call Delay(0.1) Next End Sub '********************************************************* Sub Frown() Dim x as Byte For x = 1 to 10 Call PulseOut(UpLip, 0.0014, 1) Call PulseOut(LowLip, 0.0020, 1) Call PulseOut(ELids, 0.0016, 1) Call Delay(0.1) Next End Sub '********************************************************* Sub Gasp() Dim x as Byte For x = 1 to 10 Call PulseOut(UpLip, 0.0013, 1) Call PulseOut(LowLip, 0.0013, 1) Call PulseOut(ELids, 0.0020, 1) Call Delay(0.1) Next End Sub '********************************************************* Sub Gasp2() Dim x as Byte For x = 1 to 10 Call PulseOut(UpLip, 0.0011, 1) Call PulseOut(LowLip, 0.0011, 1) Call PulseOut(ELids, 0.0020, 1) Call Delay(0.1) Next End Sub '********************************************************* Sub Squint() 'or stupid look heh Dim x as Byte For x=1 to 15 Call PulseOut(UpLip, 0.0012, 1) Call PulseOut(LowLip, 0.0012, 1) Call PulseOut(ELids, 0.0015, 1) Call Delay(0.015) Next End Sub '********************************************************* Sub VeryBigSmile() Dim x as Byte For x=1 to 60 Call PulseOut(UpLip, 0.0020, 1) Call PulseOut(ELids, 0.0019, 1) Call PulseOut(LowLip, 0.0016, 1) Call Delay(0.015) Next End Sub '********************************************************* Sub QuickSmile() Dim x as Byte For x=1 to 15 Call PulseOut(UpLip, 0.0020, 1) Call PulseOut(ELids, 0.0019, 1) Call PulseOut(LowLip, 0.0016, 1) Call Delay(0.015) Next End Sub '********************************************************* Sub Smile() Dim x as Byte For x=1 to 15 Call PulseOut(UpLip, 0.0019, 1) Call PulseOut(ELids, 0.0018, 1) Call PulseOut(LowLip, 0.0014, 1) Call Delay(0.015) Next End Sub '********************************************************* Sub Smirk() Dim x as Byte For x=1 to 15 Call PulseOut(UpLip, 0.0016, 1) Call PulseOut(ELids, 0.0018, 1) Call PulseOut(LowLip, 0.0012, 1) Call Delay(0.015) Next End Sub '********************************************************* Sub MovingEyes() 'back and forth Dim x as Byte Dim y as Byte For y = 1 to 2 For x=1 to 9 Call PulseOut(Eyes, 0.0016, 1) 'looking at face eyes move right if >.0015 Call Delay(0.015) Next Delay(1.0) For x=1 to 18 Call PulseOut(Eyes, 0.00125, 1) 'looking at face eyes move right if <.0015 Call Delay(0.015) Next Next End Sub '********************************************************* Sub Normal() 'normal face Dim x as Byte For x = 1 to 20 Call PulseOut(Elids, 0.0017, 1) Call PulseOut(UpLip, 0.0015, 1) Call PulseOut(LowLip, 0.0016, 1) Call PulseOut(Eyes, 0.0015, 1) Call Delay(0.01) Next End Sub '********************************************************* Sub BrowThing() Dim x as Byte For x=1 to 8 Call PulseOut(ELids, 0.0022, 1) 'close eyes Call Delay(0.005) Next For x=1 to 8 Call PulseOut(ELids, 0.0018, 1) 'open eyes Call Delay(0.005) Next End Sub '********************************************************* Sub FlashingLashes() Dim x as Byte Dim y as Byte For y=1 to 2 For x=1 to 9 Call PulseOut(ELids, 0.0013, 1) Call Delay(0.006) Next For x=1 to 9 Call PulseOut(ELids, 0.0019, 1) Call Delay(0.006) Next Next End Sub '********************************************************* Sub Blinking() Dim x as Byte Dim y as Byte For y=1 to 2 For x=1 to 9 Call PulseOut(ELids, 0.0013, 1) Call Delay(0.02) Next For x=1 to 9 Call PulseOut(ELids, 0.0019, 1) Call Delay(0.02) Next Next End Sub '************************************************* Public Function Reciever() as Byte Dim z as Integer Dim x as Single Dim Signal(1 to 4) As Byte Dim i As Byte Dim Max As Byte 'sets all counts in array 0 For i=0 to 3 Signal(i) = 0 Next Call PutPin(12, 2) For z = 1 to 10 Call PulseIn(12, 1, x) debug.print "x: "; cstr(x) debug.print "z: "; cstr(z) If (x > 2.7E-02) And (x < 3.3E-02) Then Signal(0) = Signal(0) + 1 End If If (x > 3.7E-02) And (x < 4.3E-02) Then Signal(1) = Signal(1) + 1 End If If (x > 4.7E-02) And (x < 5.3E-02) Then Signal(2) = Signal(2) + 1 End If If (x > 5.7E-02) And (x < 6.3E-02) Then Signal(3) = Signal(3) + 1 End If Next Max = 0 For i = 0 to 3 If Signal(i) > 1 Then Max = i + 1 End If Next Reciever = Max 'returns # corresponding to an esra End Function '********************************************************* Sub Transmit() Dim z as Integer z = 0 debug.print "called transmit" Do While z < 15 Call PulseOut(7, 1382, 1) Call Delay(0.02) 'YF debug.print "timing: "; cstr(z) z = z + 1 Loop End Sub '********************************************************* Sub Stroke() 'face with open expression Dim ServoPulses as Integer ServoPulses = 40 Dim x as Integer For x = 1 to ServoPulses ' Do this for ServoPulses number of times Call PulseOut(7, 0.0015, 1) Call PulseOut(7, 0.0015, 1) Call PulseOut(7, 0.0015, 1) Call PulseOut(7, 0.0015, 1) Call PulseOut(7, 0.0015, 1) Call PulseOut(8, 0.0015, 1) Call PulseOut(8, 0.0015, 1) Call PulseOut(8, 0.0015, 1) Call PulseOut(8, 0.0015, 1) Call PulseOut(8, 0.0015, 1) Call PulseOut(9, 0.0015, 1) Call PulseOut(9, 0.0015, 1) Call PulseOut(9, 0.0015, 1) Call PulseOut(9, 0.0015, 1) Call PulseOut(9, 0.0015, 1) Call PulseOut(10, 0.0015, 1) Call PulseOut(10, 0.0015, 1) Call PulseOut(10, 0.0015, 1) Call PulseOut(10, 0.0015, 1) Call PulseOut(10, 0.0015, 1) Next End Sub '********************************************************* Public Sub Main() Dim Etype As Byte Etype = 0 debug.print "called Main" do Etype = Reciever() Call Transmit Select Case Etype Case 1 ‘ Meets another Young Male Etype = 0 'reset x to 0 debug.print "young male" Call MovingEyes Call Delay(2.0) Call Gasp Call Delay(2.0) Call Smile Call Delay(0.5) Call FlashingLashes Call Delay(4.0) Case 2 ‘ Meets Young Female Etype = 0 'reset x to 0 debug.print "young female" Call Normal Call Delay(1.0) Call MovingEyes Call Normal Call Delay(4.0) Case 3 ‘ Meets Old Male debug.print "old man" Etype = 0 'reset x to 0 Call Normal Call Delay(1.0) Call Blink Call Delay(1.0) Call Frown Call Delay(4.0) Case 4 ‘ Meets Old Female Etype = 0 'reset x to 0 debug.print "old female" Call Normal Call Delay(1.0) Call Smile Call Delay(2.0) Call Blink Call Delay(4.0) End Select loop End Sub