Sending alternating logics to multiple pins

Discussion in 'The Projects Forum' started by Stackington21, Apr 5, 2016.

  1. Stackington21

    Thread Starter New Member

    Oct 16, 2015
    11
    0
    Hi all
    Still very basic when it comes to coding so i am a bit confused as to how reading/writing logics to ports comes about. What I am after is a sub routine that integer A will select which of the 6 pins will receive integer B to turn them on or off. I want it so any combination of leds can be on or off (so a range from 0 to 63).

    One of my first sub routines involves setting up all of the ports to be either inputs/outputs (port F is all outputs at this stage). If i want to turn on a combination of leds, would i have another initialise of my port in this subroutine to change the leds I don't want on as an input? That way when i send integer B to be a 1 value, the inputs obviously won't send that logic to the leds?

    I hope this makes sense, still trying to grasp all of this, but having a blast doing so.

    Thanks
     
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,392
    1,605
    Hello Stackington, welcome to the forums.

    We do have a forum just for micro stuff, this may get a better look if you post there, but let's try here. You might ask the mods to move it by hitting the report button.

    Usually a pin is used as either an input or an output, so that gets set once as the device starts up and never gets touched again. To turn the 6 LEDs on or off you just set the port pins hi or low. So to set the low 3 on and top 3 off you send a binary 000111, and to do the reverse you set it to 111000.

    I've assumed you have the LEDs at the lowest port pins, and I don't have a clue if you input anything. Do you have a sketch of your setup?

    Also, what device are you sing, and what programming language (C, assembler, etc) are you using?
     
Loading...