WYSIWYG Web Builder
Rick & Morty Portal Gun
2nd May 2018, Currently this is a work in progress but lets see how far we've come.

Well to start with I thought producing this would be easy but the 3D printer is playing up and have had 7 attempts at producing the case.

I downloaded then case from Thingiverse https://www.thingiverse.com/thing:1100601
I saw this and thought thats for me..
But what I got was this..
Bloody plastic warped at the end, out of 7 attempts this is probably the best so far.

Anyway, I found another portal gun on Thingiverse https://www.thingiverse.com/thing:2804288
This one is made of smaller parts so hopefully it may come out better, but hey ho we'll see.

Now you can't have a portal gun without electronics which is my speciality.. yaaaay.

I managed to get hold of an alphanumeric display from The Pi Hut, Link about £10 +£2.99 postage at time of writing.
These are I2C displays and datasheet is Here
To drive this I need a microcontroller, at first I thought of a PIC16F648a but I only had one and that packed up, so I ended up with a PIC16F688. I can't program in C or C++ never got used to the syntax, so I'm using BASIC to program the chip with a rather now dated Oshonsoft still pretty good for the smaller chips. Anyhow all you need next are 4x 10mm green LED's and a rotary encoder.
I will include a circuit and a HEX dump at some point but can't be arsed at mo as its beer o'clock..
Here'e the complete Code, which includes the font. Uses 65% of chip memory..

==================================================================

'16F688 14pin IC running at 8mhz internal clock
'18th April 2018
'Code to make a Rick Sanchez Portal Gun

AllDigital
Define STRING_MAX_LENGTH = 20
OSCCON = %01110110
TRISA = %00000111
TRISC = 0
PIE1 = 0
OPTION.7 = 0 'Weak pullup on, need these for the rotary encoder..

OPTION.6 = 0
Symbol scl = PORTC.3 'PIN 7
Symbol sda = PORTC.4 'PIN 6
Symbol front1 = PORTC.2 'Front LED's
Symbol front2 = PORTC.1
Symbol front3 = PORTC.0
Symbol bulb = PORTA.5 ' TOP LED for bulb

bulb = 0

'dimm = 1
Dim fnt As Word
Dim fnt1 As Word
Dim temp As Word
Dim temp1 As Byte
Dim flag As Bit
Dim text As String
'Dim dump As Word
Dim world As Word
Dim world_realm As Byte


world_realm = 67 'Letter C
world = 137 'Huh 137 earth



PORTC = 0

WaitMs 50

I2CPrepare sda, scl
Call front(0) ' Turns off all the front LED's
bulb = 0 ' Turns off the top bulb LED

flag = 0


Const address = 0xe0

Call init()
text = " "
Call display(text, 0)

'IOCA = 255
INTCON = %10010000


'##################################### LOOP #################

loop:

text = "RicK"
Call display(text, 1)
WaitMs 3000
Break
text = Chr(world_realm)
If world < 100 And world > 9 Then text = text + "0"
If world < 10 Then text = text + "00"
text = text + #world

Call display(text, 1)

WaitMs 3000

If world = 138 Then
bulb = 1
For temp = 1 To 100
Call front(1)
WaitMs 10
Call front(0)
WaitMs 50
Next temp
Else
Call front(0)
bulb = 0
Endif


Goto loop
'############################################################
End

Proc front(arg As Bit)
    front1 = arg
    front2 = arg
    front3 = arg
End Proc


On Interrupt
    Save System
    INTCON.INTF = 0
    INTCON.RAIF = 0
    INTCON = 0

    text = "SET "
    Call display(text, 0)

    WaitMs 1000

    text = " "

    Call display(text, 0) 'Blanking display
    I2CStart
    I2CSend 0xe0
    I2CSend 0x83 'flash display
    I2CStop

    While RA2 = 1


    text = Chr(world_realm)
    If world < 100 And world > 10 Then text = text + "0"
    If world < 10 Then text = text + "00"
    text = text + #world

    Call display(text, 0)

    While RA0 = 1 And RA1 = 1 And RA2 = 1
    Wend

    If RA0 = 0 And RA1 = 1 Then
        world = world - 1
        If world = 65535 Then
            world = 999
            world_realm = world_realm - 1
            If world_realm < 65 Then world_realm = 90
        Endif
        While RA0 = 0 And RA1 = 1
        Wend
    Endif

    If RA0 = 1 And RA1 = 0 Then
        world = world + 1
        If world > 1000 Then
            world = 0
            world_realm = world_realm + 1
            If world_realm > 90 Then world_realm = 65
        Endif
        While RA1 = 0 And RA0 = 1
        Wend
    Endif

Wend

Call init()

text = "EXIT"

Call display(text, 0)

WaitMs 1000
text = " "
Call display(text, 1)
WaitMs 1000


text = "HERE"
Call display(text, 1)
WaitMs 1000
text = " "
Call display(text, 1)
WaitMs 100
text = " WE "
Call display(text, 1)
WaitMs 1000
text = " "
Call display(text, 1)
WaitMs 100
text = " GO "
Call display(text, 1)
WaitMs 1000
text = " "
Call display(text, 1)
'WaitMs 1000

bulb = 1

WaitMs 1000


For temp = 1 To 100
Call front(1)
WaitMs 10
Call front(0)
WaitMs 50
Next temp


bulb = 0

WaitMs 1000


text = " "
Call display(text, 0) 'Blanking display
INTCON.INTF = 0
INTCON.RAIF = 0
INTCON = %10010000

Call init()

Resume

Proc display(text As String, spkl As Bit)

    Dim x As Byte
    Dim x1 As Byte
    Dim length As Byte
    Dim addy As Byte
    Dim dta As Byte
    length = Len(text)
    length = length - 1

    For x = 0 To length
        addy = x * 2
        x1 = x + 1
        dta = Asc(MidStr(text, x1, 1))

    Select Case dta
        Case 1
            fnt = %0000000000000001
        Case 2
            fnt = %0000000000000010
        Case 3
            fnt = %0000000000000100
        Case 4
            fnt = %0000000000001000
        Case 5
            fnt = %0000000000010000
        Case 6
            fnt = %0000000000100000
        Case 7
            fnt = %0000000001000000
        Case 8
            fnt = %0000000010000000
        Case 9
            fnt = %0000000100000000
        Case 10
            fnt = %0000001000000000
        Case 11
            fnt = %0000010000000000
        Case 12
            fnt = %0000100000000000
        Case 13
            fnt = %0001000000000000
        Case 14
            fnt = %0010000000000000
        Case 15
            fnt = %0100000000000000
        Case 16
            fnt = %1000000000000000
        Case 32
            fnt = %0000000000000000 '/ /
        Case 33
            fnt = %0000000000000110 '/ / !
        Case 34
            fnt = %0000001000100000 '/ / ""
        Case 35
            fnt = %0001001011001110 '/ / #
        Case 36
            fnt = %0001001011101101 '/ / $
        Case 37
            fnt = %0000110000100100 '/ / %
        Case 38
            fnt = %0010001101011101 '/ / &
        Case 39
            fnt = %0000010000000000 '/ /
        Case 40
            fnt = %0010010000000000 '/ / (
        Case 41
            fnt = %0000100100000000 '/ /)
        Case 42
            fnt = %0011111111000000 '/ / *
        Case 43
            fnt = %0001001011000000 '/ / +
        Case 44
            fnt = %0000100000000000 '/ /'
        Case 45
            fnt = %0000000011000000 '/ / -
        Case 46
            fnt = %0100000000000000 '/ /.
        Case 47
            fnt = %0000110000000000 '/ / /
        Case 48
            fnt = %0000000000111111 '/ / 0
        Case 49
            fnt = %0000000000000110 '/ / 1
        Case 50
            fnt = %0000000011011011 '/ / 2
        Case 51
            fnt = %0000000011001111 '/ / 3
        Case 52
            fnt = %0000000011100110 '/ / 4
        Case 53
            fnt = %0000000011101101 '/ / 5
        Case 54
            fnt = %0000000011111101 '/ / 6
        Case 55
            fnt = %0000000000000111 '/ / 7
        Case 56
            fnt = %0000000011111111 '/ / 8
        Case 57
            fnt = %0000000011101111 '/ / 9
        Case 58
            fnt = %0001001000000000 '/ /:
        Case 59
            fnt = %0000101000000000 '/ / ;
        Case 60
            fnt = %0010010000000000 '/ / <
        Case 61
            fnt = %0000000011001000 '/ / =
        Case 62
            fnt = %0000100100000000 '/ / >
        Case 63
            fnt = %0001000010000011 '/ / ?
        Case 64
            fnt = %0000001010111011 '/ / @
        Case 65
            fnt = %0000000011110111 '/ / A
        Case 66
            fnt = %0001001010001111 '/ / B
        Case 67
            fnt = %0000000000111001 '/ / C
        Case 68
            fnt = %0001001000001111 '/ / D
        Case 69
            fnt = %0000000011111001 '/ / E
        Case 70
            fnt = %0000000001110001 '/ / F
        Case 71
            fnt = %0000000010111101 '/ / G
        Case 72
            fnt = %0000000011110110 '/ / H
        Case 73
            fnt = %0001001000000000 '/ / I
        Case 74
            fnt = %0000000000011110 '/ / J
        Case 75
            fnt = %0010010001110000 '/ / K
        Case 76
            fnt = %0000000000111000 '/ / L
        Case 77
            fnt = %0000010100110110 '/ / M
        Case 78
            fnt = %0010000100110110 '/ / N
        Case 79
            fnt = %0000000000111111 '/ / O
        Case 80
            fnt = %0000000011110011 '/ / P
        Case 81
            fnt = %0010000000111111 '/ / Q
        Case 82
            fnt = %0010000011110011 '/ / R
        Case 83
            fnt = %0000000011101101 '/ / S
        Case 84
            fnt = %0001001000000001 '/ / T
        Case 85
            fnt = %0000000000111110 '/ / U
        Case 86
            fnt = %0000110000110000 '/ / V
        Case 87
            fnt = %0010100000110110 '/ / W
        Case 88
            fnt = %0010110100000000 '/ / X
        Case 89
            fnt = %0001010100000000 '/ / Y
        Case 90
            fnt = %0000110000001001 '/ / Z
        Case 91
            fnt = %0000000000111001 '/ / [
        Case 92
            fnt = %0010000100000000 '/ \
        Case 93      
            fnt = %0000000000001111 '/ / ]
        Case 94
            fnt = %0000110000000011 '/ / ^
        Case 95
            fnt = %0000000000001000 '/ / _
        Case 96
            fnt = %0000000100000000 '/ / `
        Case 97
            fnt = %0001000001011000 '/ / a
        Case 98
            fnt = %0010000001111000 '/ / b
        Case 99
            fnt = %0000000011011000 '/ / C
        Case 100
            fnt = %0000100010001110 '/ / d
        Case 101
            fnt = %0000100001011000 '/ / e
        Case 102
            fnt = %0000000001110001 '/ / f
        Case 103
            fnt = %0000010010001110 '/ / g
        Case 104
            fnt = %0001000001110000 '/ / h
        Case 105
            fnt = %0001000000000000 '/ / i
        Case 106
            fnt = %0000000000001110 '/ / j
        Case 107
            fnt = %0011011000000000 '/ / k
        Case 108
            fnt = %0000000000110000 '/ / l
        Case 109
            fnt = %0001000011010100 '/ / m
        Case 110
            fnt = %0001000001010000 '/ / n
        Case 111
            fnt = %0000000011011100 '/ / o
        Case 112
            fnt = %0000000101110000 '/ / p
        Case 113
            fnt = %0000010010000110 '/ / q
        Case 114
            fnt = %0000000001010000 '/ / r
        Case 115
            fnt = %0010000010001000 '/ / s
        Case 116
            fnt = %0000000001111000 '/ / t
        Case 117
            fnt = %0000000000011100 '/ / u
        Case 118
            fnt = %0010000000000100 '/ / v
        Case 119
            fnt = %0010100000010100 '/ / W
        Case 120
            fnt = %0010100011000000 '/ / x
        Case 121
            fnt = %0010000000001100 '/ / y
        Case 122
            fnt = %0000100001001000 '/ / Z
        Case 123
            fnt = %0000100101001001 '/ / {
        Case 124
            fnt = %0001001000000000 '/ / |
        Case 125
            fnt = %0010010010001001 '/ / }
        Case 126
            fnt = %0000010100100000 '/ / ~
    EndSelect

If addy > 15 Then addy = 15

If spkl = 1 Then
fnt1 = 1
'For temp = 0 To 6 Step 2
For temp1 = 1 To 16
'Call display(temp, temp1)
I2CStart
I2CSend address
I2CSend addy
I2CSend fnt1.LB
I2CSend fnt1.HB
I2CStop
WaitMs 10
fnt1 = ShiftLeft(fnt1, 1)
Next temp1
'Next temp
Endif

I2CStart
I2CSend address
I2CSend addy
I2CSend fnt.LB
I2CSend fnt.HB
I2CStop

Next x

End Proc

Proc init() 'Initialise Display

    I2CStart
    I2CSend 0xe0    'Display Address
    I2CSend 0x21    'Turn on display oscillator
    I2CStop

    I2CStart
    I2CSend 0xe0
    I2CSend 0x81     'Turn on display no blink
    I2CStop


    I2CStart
    I2CSend 0xe0
    I2CSend 0xe8     'Half brightness (e8) full brightness (ef)
    I2CStop

End Proc
=================================================================
I eventually managed to print a fairly good portal gun, just in time for the PIL (Perverts in leather) Rally.