Shop OBEX P1 Docs P2 Docs Learn Events
This is embarrassing — Parallax Forums

This is embarrassing

wirecutterwirecutter Posts: 22
edited 2011-01-28 22:56 in Propeller 1
Hello,
I am working through a book on spin programming and this bug popped up,.
"ERROR: Expected an instructio or variable"
In this section that reads:

pub Go
dira [output_pin]~~ ' set pin to output
outa [output_pin]~ ' make pin low output
dira [input_pin]~ ' set pin to input
repeat
if ina[input_pin]==0 ' check pin for high or low
turnOn_LED ' method call
else
turnOff_LED ' method call

It tells me the line " turnOn_LED" has the error
I typed it exactly as in book, can someone explain what is wrong?

it wont let me archive it.

thanks,
wirecutter

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2011-01-28 22:39
    Do you have methods named turnOn_LED and turnOff_LED in your SPIN file? If not maybe the book you mention assumes that those methods should be implemented by yourself? It would also help if you could tell us which book you are referring to.
  • wirecutterwirecutter Posts: 22
    edited 2011-01-28 22:43
    Hello,

    Here is the full code.

    {{ 12 sep 09 Harprit Sandhu
    ButtonLED.spin
    Propeller Tool 1.2.6
    Chapter 15 program 1

    Program turns on LED if input has been pulled up is grounded
    }}

    con

    _clkmode = xtal1 + pll2x ' system clock spec
    _xinfreq = 5_000_000

    input_pin = 23 ' input pin
    output_pin = 27 ' output pin
    inv_high = 0 ' invert high state
    inv_low = 1 ' invert low state

    pub Go
    dira [output_pin]~~ ' set pin to output
    outa [output_pin]~ ' make pin low output
    dira [input_pin]~ ' set pin to input
    repeat
    if ina[input_pin]==0 ' check pin for high or low
    turnOn_LED ' method call
    else
    turnOff_LED ' method call

    PRI turn_On_LED ' method to set the LED line high
    outa[output_pin] :=inv_high ' sets the LED high

    PRI turn_Off_LED ' method to set the LED line low
    outa[output_pin] :=inv_high ' sets the LED low

    The book is called "Programming the propeller with spin"
    Tab book ISBN# 978-0-07-171666-6


    Thanks,
    wirecutter
  • kuronekokuroneko Posts: 3,623
    edited 2011-01-28 22:49
    repeat
       if ina[input_pin]==0          ' check pin for high or low
         turnOn_LED                  ' method call
       else
          turnOff_LED                ' method call
        
    PRI turn[COLOR="red"]_[/COLOR]On_LED                   ' method to set the LED line high
        outa[output_pin] :=inv_high   ' sets the LED high
    
    PRI turn[COLOR="red"]_[/COLOR]Off_LED                   ' method to set the LED line low
        outa[output_pin] :=inv_high   ' sets the LED low
    
    Note the different spelling between how the methods are called and how they are defined. Looks like lousy QA/QC if that's a straight copy from the book.
  • wirecutterwirecutter Posts: 22
    edited 2011-01-28 22:56
    I guess your right, bad QA. this is the first time this happened and didn't notice it.

    thanks
    wirecutter
Sign In or Register to comment.