EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / PIC 16F84A pins into array

PIC 16F84A pins into array

|

Microcontroller › PIC › PIC 16F84A pins into array

  • This topic has 0 replies, 1 voice, and was last updated 13 years, 6 months ago by Bachra.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • December 26, 2011 at 5:34 pm #1469
    Bachra
    Participant

    Hi

     

    I’m newbie in embedded system programming but not in C/C++ or C#. Here is the situation, I want to put all the portB pins into an array to simply  use a loop that blinks some leds following a determined order here is the code so I tried to use the output_bit(pin,value) which Ifound in the mikroC library but in vain the compiler doesn’t recognise it. So how to put all those pins of the portB into an array? For thurther details here is my code:

     

    //Shift the led  to left
    void moveleft()
    {
       int i = 0;
       while(PORTB.F7!=1)
       {
         //Set the value of the pin i to 1
         output_bit(i,1);
         //Delay
         Delay_ms(1000);
         i++;
       }
    }
    //Shift the led to right
    void moveright()
    {
       int i = 7;
       while(PORTB.F7!=1)
       {
         //Set the value of the pin i to 1
         output_bit(i,1);
         //Delay
         Delay_ms(1000);
         i–;
       }
    }

    void initialize()
    {
      TRISB = 0;
       PORTB = 0xFF;
       PORTB.F0 = 0;
    }

    //The main function
    void main()
    {
       initialize();

       while(1)
       {
            if(PORTB.F7!=1) moveleft();
            Delay_ms(1000);
            if(PORTB.F0!=1) moveright();
            Delay_ms(1000);

       }
    }

     

    Thank you

  • Author
    Posts
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Can I make two inputs from one?? July 9, 2025
  • The Analog Gods Hate Me July 9, 2025
  • How to make string LEDs? July 9, 2025
  • Fixing board, Easy question HEX SCHMITT July 9, 2025
  • It's Amazing What A Buck And A Quarter.... July 8, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise