Using Variable Names When Calling a MC PIN High or Low

This is a discussion on Using Variable Names When Calling a MC PIN High or Low within the C Programming forums, part of the General Programming Boards category; I haven't tried to run my program yet, but maybe I will save some trouble if I ask this question ...

  1. #1
    Registered User
    Join Date
    Feb 2013
    Posts
    8

    Using Variable Names When Calling a MC PIN High or Low

    I haven't tried to run my program yet, but maybe I will save some trouble if I ask this question first.

    I am using MC PIC16F690, and I could make a pin high or low by writing RCx = 1 or 0, where x is the pin in the C port. However, I want to use the counter variable from a for() loop as the pin number. Will RC(variablename) = 1 work, or is there another syntax?

    Thanks....

  2. #2
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,264
    No it wont.
    If they are separate variables, and you have no say in that matter (which is probably the case), then use a switch statement.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,338
    You could look to see how RCx is defined.

    If it's something like
    #define RC1 port |= (1<<1)

    Then you can just ignore all that and write in your code loop
    port |= (1<<loopVar)
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Variable names starting with _
    By edesign in forum C Programming
    Replies: 3
    Last Post: 06-05-2009, 03:47 AM
  2. Variable object names
    By Rider in forum C++ Programming
    Replies: 4
    Last Post: 11-02-2006, 12:48 AM
  3. i j k variable names
    By swgh in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 10-12-2006, 04:25 PM
  4. Variable Names based on Variable Values
    By mrpickle in forum C++ Programming
    Replies: 6
    Last Post: 01-27-2003, 09:33 AM
  5. variable names
    By trekker in forum C Programming
    Replies: 3
    Last Post: 03-16-2002, 02:37 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21