atmega328p all RBG LED pins are high regardless of implemented code [SOLVED]

Recently, I have been trying to shrink my projects down by uploading my code on an Atmega328p chip off of an Arduino Uno board then remove the chip and attach it to a breadboard with a 16 MHz crystal and 2 20 pF caps. The current project I'm working on involves an RGB (common anode) LED that glows red when the temperature goes over a threshold and changes to blue when the temperature is under the threshold. While attached to the Uno, the code works beautifully, but when I try and power up the same chip off the Arduino board it won't even turn on. Here is my code:

#include "max6675.h"

const byte COLOR_BLACK = 0b000;
const byte COLOR_RED = 0b100;
const byte COLOR_GREEN = 0b010;
const byte COLOR_BLUE = 0b001;
const byte COLOR_MAGENTA = 0b101;
const byte COLOR_CYAN = 0b011;
const byte COLOR_YELLOW = 0b110;
const byte COLOR_WHITE = 0b111;

int temp = 0;
int thresh = 30;

const byte PIN_LED_R = 3;
const byte PIN_LED_G = 5;
const byte PIN_LED_B = 6;

int ktcSO = 8;
int ktcCS = 9;
int ktcCLK = 10;

MAX6675 ktc(ktcCLK, ktcCS, ktcSO);

void setup() {

  pinMode(PIN_LED_R, OUTPUT);
  pinMode(PIN_LED_G, OUTPUT);
  pinMode(PIN_LED_B, OUTPUT);

void loop() {

  temp = ktc.readCelsius();

  if (temp >= thresh) {
  else {

void displayColor(byte color) {

  digitalWrite(PIN_LED_R, !bitRead(color, 2));
  digitalWrite(PIN_LED_G, !bitRead(color, 1));
  digitalWrite(PIN_LED_B, !bitRead(color, 0));

My circuit is powered by a 9V battery passes through a 5V voltage regulator. To power the chip off the board
Here is the schematic of the chip with the LEDs (I omitted the thermocouple because the issue is present with and without it): (See attachments)

I have tried to measure the voltage on each LED pin and found something interesting. The anode (longest pin) pin had the expected 5V but two pins had 3V and the last one 3.5V. I checked this in reference to when the chip is on the Uno board and I get 5V on the anode pin, 5V on the Red and Green pins and 0v on the Blue pin. (Keep in mind I did not have the 220-ohm resistors in the circuit when it was attached to the Arduino so it makes sense for the output voltage to be 5v instead of 3v. This means that the blue pin getting 5V when it shouldn't be. What could have caused this and how should I account for issues of this nature in the future?

Have you checked whether your ATmega328P is working on the breadboard with a basic blink sketch, and without the extra circuitry attached?

Briskgotmethrough's RHJ.jpg:

You should have a 0.1 uF capacitor on each of the power lines, right next to the ATmega328P. Like this:

I have tried the blink example and it works fine. I'll try adding the 0.1uF caps and see if they fix the problem.

Quick update: Tried the blink example and it's not working anymore. Could this be a problem with the chip?

Could be. Have you tried putting the chip back into the Uno board and tried the blink example? That would narrow down the cause of the problem.

BJHenry, I just finished doing that and it works without a hitch. I measured the voltage on pin 13 when it was on the breadboard and I'm getting 0V but on other pins, I'm getting 0.3-1V. I'm powering the chip with a constant 5v power supply so I'm not sure where the voltage is going.

Here is a picture of my current setup:


Just to clarify, you're saying that your sketch works fine when the chip is in the Uno board, but doesn't work correctly when you take it out of the Uno and put in in the breadboard?

Out of curiosity, what voltage are you seeing on the Reset pin of the chip when it is on the breadboard?

I'm with BJHenry.

Just checked my push button switches (look exactly like yours) and if I am reading your picture correctly, the photo is not 100% clear, you have the push button orientated to permanently connect the reset to ground.


Wilem43, yeah I just noticed that. it was setting the reset pin to 0V (when I checked the voltage) The code works now! Thank you all for your help! It's always the small things that get me...

Glad you sorted it.


I'm glad you got it sorted :slight_smile: Thanks for letting us know.