Shop OBEX P1 Docs P2 Docs Learn Events
Inputs — Parallax Forums

Inputs

ThePwnStickThePwnStick Posts: 6
edited 2008-12-19 15:08 in Propeller 1
Hi all.

I'm new to propeller, and I still can't figure out how to detect when a button switch is pressed.

Can someone please help?

Also, how do I clear the EEPROM?

Post Edited (ThePwnStick) : 12/19/2008 5:13:54 AM GMT

Comments

  • T ChapT Chap Posts: 4,223
    edited 2008-12-19 05:50
    You may need to restate your questions with a few more details to help figure out what you are wanting to accomplish.

    For the first part:

    Do you have a switch connected to the prop? What type of switch, and is the pin pulled up or down with a resistor to hold the pin in a certain state when the button is not pressed?

    Do you have an LED, LCD, buzzer, or TV connected to give feedback on a button press?

    You'd need to set the pin as input ( dira[noparse][[/noparse]pin] := 0) , and use one of various commands that check for a pin state change, IF is a basic method to do this:
    
    repeat 
       If ina[noparse][[/noparse]pin] == 1
           '  do something for feedback here
    
    




    For the second part:

    Why do you want to clear the EEPROM? It is easy enough to write anything you want over any or all EEPROM memory locations with PageWrite in the Basic or Minimal I2C objects, but I suspect what you are asking is not really how to clear the EEPROM

    Post Edited (TChapman) : 12/19/2008 6:11:08 AM GMT
  • ThePwnStickThePwnStick Posts: 6
    edited 2008-12-19 06:09
    First: It's a momentary push switch. You know, you push it and it turns off. You lift your finger and it turns off. And yes I have LEDs.

    Second: Well, is there any way to reset the EEPROM to the default program?

    EDIT: Ok, thank you. This works perfectly.
  • SRLMSRLM Posts: 5,045
    edited 2008-12-19 06:14
    Take a look at the PE labs (in the stickies) They do all sort of simple uC options, and button is probably one of them.
  • Ken PetersonKen Peterson Posts: 806
    edited 2008-12-19 14:30
    The easiest way to "clear" the EEPROM is the load the following "null" program

    pub main
    
    

    "main" can really be anything.· It's just a program with one function that does nothing.· I keep a copy of it called null.spin that I use to blank out a prop board so I can work on the hardware.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"I have always wished that my computer would be as easy to use as my telephone.· My wish has come true.· I no longer know how to use my telephone."

    - Bjarne Stroustrup

    Post Edited (Ken Peterson) : 12/19/2008 2:36:03 PM GMT
  • StefanL38StefanL38 Posts: 2,292
    edited 2008-12-19 15:08
    Hello,

    there is no default program
    whenever you write into the EEPROM the content before gets overwritten.

    If you want to test that your propeller-chip is still OK first step is to just detect your propellerchip by pressing F7

    Next step is to load one of the demoprograms from the propellerdirectory

    best regards

    Stefan
Sign In or Register to comment.