Help Quick Need to make code smaller


Results 1 to 40 of 42

Threaded View

  1. #8
    Programmednew's Avatar
    Programmednew Guest


    Did you find this post helpful? Yes | No

    Default

    I changed the code to

    DEFINE OSC 4
    Input PORTA.2
    High PORTA.2
    Pause 50
    Input PORTB.2
    Input PORTB.3
    Input PORTB.4
    Input PORTB.5
    Input PORTB.6
    Input PORTA.4
    Horncount VAR BYTE
    CounterStop VAR BYTE
    SWITCH:
    Pause 250
    IF PORTA.4 = 1 Then End
    IF (PORTB.2 = 0) AND (PORTB.3 = 0) AND (PORTB.6 = 0) AND (PORTB.4 = 0) AND (PORTB.5 = 1) Then CounterStop = 9: GoTo Horn_Loops
    IF (PORTB.2 = 0) AND (PORTB.3 = 0) AND (PORTB.6 = 0) AND (PORTB.4 = 1) AND (PORTB.5 = 1) Then CounterStop = 0: GoTo Horn_Loops
    IF (PORTB.2 = 1) AND (PORTB.3 = 0) AND (PORTB.6 = 0) AND (PORTB.4 = 0) AND (PORTB.5 = 1) Then CounterStop = 1: GoTo Horn_Loops
    IF (PORTB.2 = 1) AND (PORTB.3 = 0) AND (PORTB.6 = 0) AND (PORTB.4 = 1) AND (PORTB.5 = 1) Then CounterStop = 2: GoTo Horn_Loops
    IF (PORTB.2 = 0) AND (PORTB.3 = 0) AND (PORTB.6 = 1) AND (PORTB.4 = 0) AND (PORTB.5 = 1) Then CounterStop = 3: GoTo Horn_Loops
    IF (PORTB.2 = 0) AND (PORTB.3 = 0) AND (PORTB.6 = 1) AND (PORTB.4 = 1) AND (PORTB.5 = 1) Then CounterStop = 4: GoTo Horn_Loops
    IF (PORTB.2 = 1) AND (PORTB.3 = 0) AND (PORTB.6 = 1) AND (PORTB.4 = 0) AND (PORTB.5 = 1) Then CounterStop = 5: GoTo Horn_Loops
    IF (PORTB.2 = 1) AND (PORTB.3 = 0) AND (PORTB.6 = 1) AND (PORTB.4 = 1) AND (PORTB.5 = 1) Then CounterStop = 6: GoTo Horn_Loops
    IF (PORTB.2 = 0) AND (PORTB.3 = 1) AND (PORTB.6 = 0) AND (PORTB.4 = 0) AND (PORTB.5 = 1) Then CounterStop = 7: GoTo Horn_Loops
    IF (PORTB.2 = 0) AND (PORTB.3 = 1) AND (PORTB.6 = 0) AND (PORTB.4 = 1) AND (PORTB.5 = 1) Then CounterStop = 8: GoTo Horn_Loops
    GoTo SWITCH
    Horn_Loops:
    For Horncount = 0 TO CounterStop
    PulsOut PORTA.2, 50000
    Pause 500
    Next Horncount
    End

    It did compile but I have another problem now. Its is with the circuit. I have attached a picture of the schematic. In it with with everything hooked up U2 overheats. Without the PIC in it it has a five volt output.
    Attached Files Attached Files

Similar Threads

  1. Code doesn't work on 16F648A
    By Mr_Joe in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 1st September 2018, 23:09
  2. Cordic trig assembly code for PIC18f
    By ScaleRobotics in forum mel PIC BASIC Pro
    Replies: 54
    Last Post: - 8th September 2015, 06:36
  3. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 22:31
  4. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 09:26
  5. Replies: 1
    Last Post: - 31st August 2005, 21:00

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts