Shop OBEX P1 Docs P2 Docs Learn Events
Need help in Propeller Demo Board (Blinkink an LED) — Parallax Forums

Need help in Propeller Demo Board (Blinkink an LED)

NikosGNikosG Posts: 705
edited 2010-12-27 10:12 in Propeller 1
Hello everybody,
I've taken the great decision to start with Propeller.! (I have already run successfully some amazing damos with sound, TV-monitor, mouse etc.!!! Actually those demos are very sophisticated and amazing!!!)
I have the propeller demo board and I'm trying to Blinkink an LED about once a second
Althought the led lights up it is not blinkink (I use a 220Ω resistor instedad off the 100Ω resistor that suggest the activity. p.p.31 book "Programming the propeller with spin. A beginner's guide to parallel".
(I have aslo changed the Output_pin from 27 to 3 because the Demo doard doesn't have freethe pin27, and I have also connected: Vss---Negative leg of the LED----Positive leg of the LED
220Ω Resistor
PIN 3)
Could you help me please?
What is wrong?
here is the code:


CON
_clkmode = xtal1 + pll2x
_xinfreq = 5_000_000 'Note Clock Speed for your setup!!

inv_hight = 0
inv_low = 1
waitPeriod = 5_000_000 ' 1/2 sec switch cycle
output_pin = 3
VAR

pub go
dira [output_pin]~~
outa [output_pin]~~
repeat
turnOff_LED
wait
turnOn_LED
wait

PRI turnOn_LED
outa[ output_pin]:=inv_hight

PRI turnOff_LED
outa[ output_pin]:=inv_low

PRI wait
waitCnt(waitPeriod+cnt)


Thank you in advance
Nikos.
P.s. I feel a bit embarrassing with this question I know that even 14year old users have achieved this task, But I have stuck.

Comments

  • ElectricAyeElectricAye Posts: 4,561
    edited 2010-12-26 11:38
    Nikos,

    When you post code, place your code between code tags, like what you see below but be sure to remove all of the spaces I placed between the brackets.

    [ code ]

    [ / code ]

    Without the code tags, the indentation is lost and it's hard to read your code.
  • Mike GMike G Posts: 2,702
    edited 2010-12-26 12:27
    The code works fine
    CON
     _clkmode = xtal1 + pll2x
     _xinfreq = 5_000_000 'Note Clock Speed for your setup!!
    
     inv_hight = 0
     inv_low = 1
     waitPeriod = 5_000_000 ' 1/2 sec switch cycle
     output_pin = 3
     
    VAR
    
    pub go
      dira [output_pin]~~
      outa [output_pin]~~
      repeat
        turnOff_LED
        wait
        turnOn_LED
        wait
       
    PRI turnOn_LED
      outa[ output_pin]:=inv_hight
    
    PRI turnOff_LED
      outa[ output_pin]:=inv_low
    
    PRI wait
      waitCnt(waitPeriod+cnt)
    

    This works too
    CON
     _clkmode = xtal1 + pll2x
     _xinfreq = 5_000_000 'Note Clock Speed for your setup!!
    
     waitPeriod = 5_000_000 ' 1/2 sec switch cycle
     LED = 3
     
    VAR
    
    PUB Main
      dira[LED]~~
      outa[LED]~~
      
      repeat
        blink
       
    PRI Blink
      !outa[LED]
      waitCnt(waitPeriod+cnt)
    
    
  • MagIO2MagIO2 Posts: 2,243
    edited 2010-12-26 12:40
    Maybe you counted wrong? The numbers of pins start with 0. First pin of the propeller is called PIN 0 .... So maybe you attached the LED to the wrong pin. So the LED should be attached to the 4th pin (PIN 3) ;o)

    At least this would be a very classic mistake.
  • ElectricAyeElectricAye Posts: 4,561
    edited 2010-12-26 12:52
    MagIO2 wrote: »
    Maybe you counted wrong? The numbers of pins start with 0. First pin of the propeller is called PIN 0 .... So maybe you attached the LED to the wrong pin. So the LED should be attached to the 4th pin (PIN 3) ;o)

    At least this would be a very classic mistake.

    Good idea! I'm always getting messed up by that pin numbering scheme. I never get used to it. :)
  • NikosGNikosG Posts: 705
    edited 2010-12-27 02:41
    Thank you guys!!!
    I didn't expect such response! Thank you all of you!
    I copyed -Paste both codes that send Mike on my propeller tool and it works! I don't know what I have done wrong. I kept the same circuit and I only run Mike's code and it works!!!
    Anyway I'm thankfull. I'll try to do the best using my propeller. I have been studying propeller and spin for 3-4 days (during Christmas holydays) and I'm fascinated. I feel that I can do a lot of things using this tool. I hope that I will be able to contribute to propeller comunity in the near future!


    Happy holydays and Happy New Year!!!!
  • HumanoidoHumanoido Posts: 5,770
    edited 2010-12-27 03:05
    NikosG, remember that SPIN code requires proper special indentation or it won't work! The original code you posted did not show any formatting. For example, the repeat statement will require indented instructions under it that apply.
  • NikosGNikosG Posts: 705
    edited 2010-12-27 04:29
    Humanoido wrote: »
    NikosG, remember that SPIN code requires proper special indentation or it won't work! The original code you posted did not show any formatting. For example, the repeat statement will require indented instructions under it that apply.

    Thank you "Humanoido"!
    I think you are right. This was my fault. I hadn't have any indented instruction under my repeat command.
    P.s.
    In my case I absolutely need a second brain to correct syntax and spelling mistakes
    If you extend your project "Fill the Big Brain" to humans I'll be one of the first customers :)
  • HumanoidoHumanoido Posts: 5,770
    edited 2010-12-27 10:12
    NikosG wrote: »
    Thank you "Humanoido"! In my case I absolutely need a second brain to correct syntax and spelling mistakes
    If you extend your project "Fill the Big Brain" to humans I'll be one of the first customers :)
    Ha! It's an open source project so when it's completed, you're welcome to it! Yes, it would be nice to extend our human brains. The trick currently is transferring the data from the human brain. A number of companies now have devices that can scan the brain and show limited pictures of what you're thinking (like an X or a circle). Some day this technique may become advanced enough where man and machine can interface and data transfer.
Sign In or Register to comment.