element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Using PORT() for data
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 9 replies
  • Answers 4 answers
  • Subscribers 391 subscribers
  • Views 664 views
  • Users 0 members are here
  • strings
  • 7-segment-display
  • port manuplation
Related

Using PORT() for data

billpenner
billpenner over 9 years ago

This is probably a very easy question for someone out there but It has me stumped. I have a three digit number like 123 or 286 etc. I am sending it from a Mega to NRF24l01+. This is working fine.

I am receiving the number fine with another NRF24l01+ and a Nano. now the problem. I have a 3 digit, 7 segment display. It is also working fine when using this code for a test..

 

[code]

/*Select a seven segment digit () in sequence.

* load a value into display for testing

*/

int i ;

byte j = B0000 ;              //the digit value (0 to 9)

 

void setup()

{

   DDRC = DDRC | B00111111;    // set PORT C (digital 5~0) to outputs

  pinMode(6, OUTPUT);               // digit select pins (Latch signal)

  pinMode(7, OUTPUT);

  pinMode(8, OUTPUT);

Serial.begin(9600);

}

 

void loop() {

for (i = 6; i <9 ; i++)       //digit select latch

  {

  digitalWrite(i, HIGH);      // open latch

    delay(100);

    for (j = 0; j <10 ;  j++) // test values for the display

     {

       PORTC = j;             // write HEX value to digit

      // Serial.print( PORTD ) ;    // just for testing

      // Serial.print( PORTC ) ;     // just for testing

       delay(100); //

     }

     delay(500);  // wait a bit to read digit

     digitalWrite(i, LOW);      // close latch

     delay(1000);

       Serial.println( byte(i)) ; //only for testing

   }

   if(i == 9, i=6);  //reset digit counter and do it again

}

[/code]

when I run the above code each digit counts up the latches then the next digit counts up. At he end.all is reset and repeats.

My problem is I can't isolate each of the received digits to individually load them into the display. Is there a way to separate the received number into digits so I can load the port? I hope this makes sense.

I can supply the schematic, video, etc.  if it would help.

 

Bill

  • Sign in to reply
  • Cancel
Parents
  • clem57
    0 clem57 over 9 years ago

    I think you need this Adafruit customer service forums • View topic - How to convert a string to a number . It can take 1 cgar at a time and convert to a number.

    Clem

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
  • billpenner
    0 billpenner over 9 years ago in reply to clem57

    I think both these do about the same thing, but I am separating the digits from the number not building a number from the digits.

    Thanks again everybody.

    ps. How do I do a "Helpful"? I see the "Correct answer" but I would like to also do Helpful.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • clem57
    0 clem57 over 9 years ago in reply to billpenner

    Below each post is  :

     

    Like Show 0 Likes(0) • Helpful Yes | No • Comment • ReportActions

     

    Click on Yes if helpful.

    Clem

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • billpenner
    0 billpenner over 9 years ago in reply to clem57

    OK I got it. I tried to mark them without signing in.

    They show up now.

    Thanks,

    Bill

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • billpenner
    0 billpenner over 9 years ago in reply to clem57

    OK I got it. I tried to mark them without signing in.

    They show up now.

    Thanks,

    Bill

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube