Shop OBEX P1 Docs P2 Docs Learn Events
Help wanted. How can I change variables with switches? — Parallax Forums

Help wanted. How can I change variables with switches?

ArchiverArchiver Posts: 46,084
edited 2002-09-26 15:14 in General Discussion
Hello.

Help wanted.
I am a newcomer.
Please show me anybody how I can change variables with switches.
Like this:

a var byte
a = 1

How I can change the variable a with a switch? (from 1 to 10)
I have tried this with subroutines but maybe know anybody another way?
Therefore:

switch one on a = 1
switch two on a = 5
switch three on a = 10

This is a little bit code with the variable:

FOR level = 0 TO 255 Step a 'a is the variable I will change
PWM Pin1,level,25
gosub delay
NEXT

Best regards, Kai



[noparse][[/noparse]Non-text portions of this message have been removed]

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-09-26 15:14
    Well it's not often I can answer a question so here goes( and I
    hope I'm right)
    By using either the inL for inputs 0 to 7 or inH for inputs 8 to
    15 you can read a 8 bits or a byte of data which is arranged by
    pins 7 6 5 4 3 2 1 0

    128 64 32
    16 8 4 2 1


    so if pins ( or switches in you case ) 1,3,5 are on you have
    2+8+32 or 42 with this you can get all numbers from 0 to 255

    Larry Gaminde

    Original Message
    From: "Kai Kuehle" <kai@u...>
    To: <basicstamps@yahoogroups.com>
    Sent: September 25, 2002 10:50 PM
    Subject: [noparse][[/noparse]basicstamps] Help wanted. How can I change variables
    with switches?


    Hello.

    Help wanted.
    I am a newcomer.
    Please show me anybody how I can change variables with switches.
    Like this:

    a var byte
    a = 1

    How I can change the variable a with a switch? (from 1 to 10)
    I have tried this with subroutines but maybe know anybody another
    way?
    Therefore:

    switch one on a = 1
    switch two on a = 5
    switch three on a = 10

    This is a little bit code with the variable:

    FOR level = 0 TO 255 Step a 'a is the variable I will change
    PWM Pin1,level,25
    gosub delay
    NEXT

    Best regards, Kai



    [noparse][[/noparse]Non-text portions of this message have been removed]


    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the
    Subject and Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/
Sign In or Register to comment.