Schedule‎ > ‎

Lab 10 Resistor Codes not done

Project : Resistor Color Codes

In this project you write a program to convert resistor color codes to ohm values.

Specifications

  1. Start with a new sketch and save the sketch using the name resistor_codes.
  2. Write a program that takes in three-band resistor color code in the following shorthand notation:
    BA  Black
    BO  Brown
    R   Red
    O   Orange
    Y   Yellow
    GE  Green
    BU  Blue
    V   Violet
    GA  Gray
    W   White
    
  3. The program gets the three band color codes one at a time with prompts for each value, like:
    Enter the first band (GE)
    Enter the second band (BU)
    Enter the multiplier band (BO)
    
  4. After obtaining the three band color codes, the program displays a full description like:
    Green Blue Brown is 560 ohms
    
  5. The shorthand color codes must work with either upper or lower case letters.
  6. Write the following function, which is called three times, to convert color codes to numbers
    int codeValue(String code)
    
  7. After converting one set of codes, allow the user to convert other codes as shown below in the example output.
  8. In your header show the operation of your program for the following shorthand color codes and at least two original code sequences, with the program name as a heading.
    GE BU BA
    r v y
    
  9. Submit your resistor_codes.ino file as part of this assignment.

Hints and Explanations

  • Use while (!Serial.available()); to block while waiting for user input
  • Use the trim() function to remove newline characters from a String variable.
  • Use equalsIgnoreCase() for comparisons to allow both upper and lower case letters in the codes.
  • Use String concatenation to build the ohms value.
  • Alternatively,  use a switch statement to produce the multiplier.  Avoid the pow() function because of limited floating point precision.
  • To print a variable of type double without decimal places use: Serial.print(variable, 0).

Example Output

Enter the first band (GE)
Enter the second band (BU)
Enter the multiplier band (BO)
Green Blue Brown is 560 ohms

Enter the first band (r)
Enter the second band (v)
Enter the multiplier band (o)
Red Violet Orange is 27000 ohms

Enter the first band (BO)
Enter the second band (BA)
Enter the multiplier band (BU)
Brown Black Blue is 10000000 ohms
Comments