# Category Archives: code

## Resistor Color Code Calculator

Category : code JavaScript

I’ve started to learn JavaScript and my first self-assignment task was to program a resistor color code calculator, wich I always wanted to code. You can check it out here! I also strongly recommend the JavaScript course that I’m taking. It’s inexpensive and you can learn very fast. I’m taking a course with Jonas Schmedtmann for the second time. It’s worthy taking a look here.

No more runaround. If you are a beginner in electronics or if you are a little rusty this post is for you! Here I’ll explain how the resistor color code works so you can know the resistance value just by seeing the colored strips printed on an axial lead resistor. If you don’t want to memorize the code you can just use my 4-band or 5-band resistor type calculator to find out the resistance value. You’re welcome!!

As said in PRACTICAL ELECTRONICS FOR INVENTORS, “Axial lead resistors, such as carbon composition, carbon film and metal film, use color bands to indicate resistance values. The most common labeling scheme uses four bands: the first band represents the first digit, the second band the second digit, the third band the multiplier (as an exponent of 10), and the fourth band the tolerance (if there is no fourth band, the tolerance is 20%).” . The table 1 shows the meaning of each band relating to its position.

 4-band 5-band 1st band 1st significant digit 1st significant digit 2nd band 2nd significant digit 2nd significant digit 3rd band multiplier 3rd significant digit 4th band tolerance multiplier 5th band tolerance

Table 1 – Meaning of resistor bands.

The table 2 indicates the meaning of each color in regard to digit, multiplier and tolerance.

 Band Color Digit Multiplier Tolerance Black 0 x100 Brown 1 x101 ± 1% Red 2 x102 ± 2% Orange 3 x103 Yellow 4 x104 Green 5 x105 ± 0.5% Blue 6 x106 ± 0.25% Violet 7 x107 ± 0.1% Gray 8 x108 ± 0.05% White 9 x109 Gold x10-1 ± 5% Silver x10-2 ± 10%

Table 2 – Resistor Color Code

For example, we can check the resistance value of the first resistor at the picture above. The first band is brown with value of 1, the second band is black with value of 0, the third band is red with a 100 as multiplier and the fourth band is gold with tolerance of ± 5%. So the resistance is equal to 10 x 100 ± 5% = 1 KΩ ± 5%. In other words, the value is between 950 Ω – 1.05 KΩ. The second example is with the second resistor at the picture above. It’s a 5-band resistor with an extra digit normally used for greater accuracy. The first band is brown with value of 1, the second band is black with value of 0, the third band is also black with value of 0, the fourth band is red with a 100 as multiplier and the fifth band is brown with tolerance of ± 1%. So the resistance is equal to 100 x 100 ± 1% = 10 KΩ ± 1%. In other words, the value is between 9.9 KΩ – 10.1 KΩ.

Note that, in reality, the beige-colored body of a resistor is often an indication that its tolerance is 5%, while a blue-colored body often indicates a tolerance of 1% or 2%. There is also a 6-band resistor that includes a temperature coefficient band but I haven’t implemented it. Just remember to read the resistor from left side to right. Usually the gold or silver bands (for tolerance) are present on the right side.

That is it for today. I hope you enjoyed and learned something new! See you around!! 😄

## Having fun learning Python and Turtle Module

Tags :

Category : code Python

I’ve started to learn Python and during this process I’ve found the turtle module, that turned out to be a funny way to practice my recent acquired abilities to write flow control, function declaration, working with random library and so on.

I’ve enjoyed it so much that I’ve decide to create a little animation and share this with the world! I definitely indicate the Turtle module for Python students, specially for kids.

So, what exactly is the Turtle module? It’s a popular way for introducing programming to kids. You can control a robotic turtle starting at (0, 0) in the x-y plane. This way you can draw primitive and complex geometric forms to create animations and games. You can check out the Turtle documentation here.

My animation is a project for beginners in Python. It shows some experiments with the turtle module, like drawing some alphabet letters, changing a turtle to a GIF image and drawing a bunch of circles. It also uses the random library to change colors and circle positions randomly.

Check out also a YouTube video with the animation here!

Below you’ll find a piece of code showing the function created to draw circles with random location, radius and color. You can download the complete project in my GitHub repository here.

You can find links here to the turtle module documentation, the inspiration code to draw the alphabet with a turtle, the code example with Georgia’s spirals and a YouTube tutorial with the basic functions explained.

I hope you try out this module and have a lot of fun!! I’ll see you around!

## Have you ever heard about HackerRank!?

Category : code

HackerRank is a technology hiring platform that enables tech recruiters to evaluate the job candidate objectively. I wanted to brush up on my C programming language knowledge and start do learn C++ when I ran into HackerRank.

This platform is fantastic! You can solve several problems to achieve a high level of programming language proficiency in C, C++, Java, Python,
, etc. There are also tutorials like “30 Days of Code” and “10 Days of Statistics”. I particularly liked the “Problem Solving” section, it sharpens your ability to think outside the box. It is noteworthy that every proposed problem has a “Discussions” section where you can talk about the solution with other people.

They have a star reward system, that motivates you to keep programming, and a coin called “Hackos”, which also stimulates you to keep the attendance and helps you with problems solution. In addition, there is the “Leaderboard” organized by subjects. In this way, the platform works like a game and you don’t feel you are studying.

They have so many features that I haven’t had the chance to look into everything. For example, they also helps you to develop specialized skills like Artificial Intelligence, SQL and Databases and Regex.

You can check out my profile and the way I solve the problems at this link! If you want to point out where I can improve the code, please let me know!!

I hope you have a lot of fun with HackerRank!! Enjoy it!