CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug Reports on this forum. Send them to support@ccsinfo.com

Color Code of Resistor

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ailee



Joined: 29 Aug 2016
Posts: 7

View user's profile Send private message

Color Code of Resistor
PostPosted: Fri Jan 14, 2022 3:23 am     Reply with quote

Hey, guys!
I created a resistor(https://www.apogeeweb.net/electron/a-guide-to-color-code-of-resistor.html) program that calculates resistance from colors, but I'm not sure how to convert resistance to color. Can you assist me with putting this together?
For example, if I enter 100 ohms and a 5% tolerance, the hues brown, black, brown, and gold appear.
temtronic



Joined: 01 Jul 2010
Posts: 8288
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Jan 14, 2022 6:15 am     Reply with quote

Which PIC are you using and GLCD ?
The actual algorithm is fairly simple, just write down the steps YOU take as a human to decode a 'value' into the bands of colour.
You'll probably want to use an array of ten positions to reference colour vs position value.
How you do it depends on how you enter the resistor value.
100r for 100 ohms, 1M5 for 1,500,000 ohms, 27K for 27,000 ohms
Different parts of the World use different ways when looking at resistors.
I can see that having a 'parser' to make turn the 'entered value' into an unsigned integer might be a good 1st step.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group