ATMEGA328 standalone on proto board

Hello All,
I have an Arduino UNO with a working script. I then made an Arduino on a protoboard and placed the ATMEGA328 into the 28 pin dip on the protoboard. I also made a voltage regulator and added that to the protoboard a 7805 12 to 5v.

I then gave the protoboard 12v from a bench power supply.

Problem: So far I get 5v readings on some of the digital pins but not all. I am confused about the pins from the Arduino compared to the Atmega328.

I am only getting 5v on pin 14, none on pins 11,12,13 on the left side of the amega328. I have 5v on pins 15 thru 21 and pins 23 & 24

Shouldn't I have 5v on pins 11,12 and 13 too?

Please advise

Thanks

Are you referring to Arduino digital pins 11, 12 and 13 or ATmega328 pins 11, 12 and 13 ?

Please post the sketch that you have loaded on the chip

I am referring to the pins on the atmega328 that is missing 5v on pins 11,12,13 pin 14 has 5v.

on my Arduino UNO I am feeding 5v to 4 leds with pins 6, 7, 10 & 11

#include "KTS_Button.h"
#define ARRSIZE(x) sizeof(x) / sizeof(x[0])

#define BLINK_INTERVAL 100
#define LONG_PRESS_TIMEOUT 600

#define BTN_ONE_PIN 8
#define BTN_TWO_PIN 5
#define LED_LOW_L 6
#define LED_LOW_R 7
#define LED_HIGH_L 10
#define LED_HIGH_R 11

//#define BTN_ONE_PIN 8
//#define BTN_TWO_PIN 5
//#define LED_LOW_L 6
//#define LED_LOW_R 7
//#define LED_HIGH_L 10
//#define LED_HIGH_R 11
KTS_Button buttons[] = { BTN_ONE_PIN, BTN_TWO_PIN };
byte leds[] = { LED_LOW_L, LED_LOW_R, LED_HIGH_L, LED_HIGH_R };

void setup() {
for (byte i = 0; i < ARRSIZE(leds); i++)
  pinMode(leds[i], OUTPUT);
//buttons[1].setLongPressTimeout(LONG_PRESS_TIMEOUT);
buttons[1].setLongPressTimeout(3000);

}

void loop() {
static uint32_t timeCapture;
static bool highBeam = false;
static bool lightsOn = true;

ActionType btnOneAction = buttons[1].read();

if (btnOneAction == SINGLE_PRESS && lightsOn)
  highBeam = !highBeam;
else if (btnOneAction == LONG_PRESS)
  lightsOn = !lightsOn;

if (buttons[0].isHeld() && lightsOn) {
  if ((millis() - timeCapture) > BLINK_INTERVAL) {
    timeCapture = millis();
    for (byte i = 0; i < (highBeam ? 4 : 2); i++)
      digitalWrite(leds[i], !digitalRead(leds[i]));
}
}
else {
  for (byte i = 0; i < ARRSIZE(leds); i++) {
    if (i < 2)
      digitalWrite(leds[i], lightsOn);
    else
      digitalWrite(leds[i], highBeam && lightsOn);
  }
}
}

Why does the diagram say "12V" on pin 1?

Are you intending to use a high voltage programmer?

12v on pin 1 of your 328p - that's not good. :boom:

I plan on running two 12v, 3a fog lights on my Harley Davidson, I will be adding a N channel MOSFET later on the protoboard to handle the 12v fog lights

12V on pin 1 is used solely for high voltage programming. Apply 12V to any other pin and the ATmega will be instantly destroyed.

Please study this excellent tutorial on construction of a "bare bones" Arduino: Gammon Forum : Electronics : Microprocessors : How to make an Arduino-compatible minimal board

I am powering the protoboard with 12v from a bench power supply to eventually power two 12v fog lights

I know that is why I used a voltage regulator to drop the 12v to 5v tor the atmrga328. I need 12 v to power my fog lights with an N channel MOSFET I will add later. The 12 on pin 1 was there with this setup. I am not familiar with the atmega328.

I have a working circuit with the fog lights using an attiny with a blink sketch on it. I want to blink my foglights with a mom-on button at will. It all works.

Then the tutorial I linked should be a great help.

ok thanks I will check it out

Why do you expect 5v on the digital pins? They will only be 5v if your code is setting them to logic HIGH. Is that what your code does?

Also - GPIO pins 5 & 8 (ATMEGA328 pins 11 & 14) look like they are being used as button inputs... so they will only high if they are being pulled high (INPUT_PULLUP), as they don't seem to be connected to anything - maybe this is done in the KTS_Button library?

Thank you red_car. I think I got it now. Here is what I think I will have to do in my script. Please tell me what you think. Thanks

//original script pin out here 
#define BTN_ONE_PIN 8
#define BTN_TWO_PIN 5
//LED's
#define LED_LOW_L 6
#define LED_LOW_R 7
#define LED_HIGH_L 10
#define LED_HIGH_R 11
*/
// new pin layout for arduino uno "cleaned it up"
#define BTN_ONE_PIN 4
#define BTN_TWO_PIN 5
//LED's
#define LED_LOW_L 6
#define LED_LOW_R 7
#define LED_HIGH_L 8
#define LED_HIGH_R 9


// *for atmega328 standalone pin out, hope this is it.
#define BTN_ONE_PIN 6 //button pin 8 on arduino uno
#define BTN_TWO_PIN 11 //button pin 5 on arduino uno
//LED's
#define LED_LOW_L 12 //led pin 6 on arduino uno
#define LED_LOW_R 13 // led pin 7 on arduino uno
#define LED_HIGH_L 14 // led pin 10 on arduino uno
#define LED_HIGH_R 15 // led pin 11 on arduino uno

I think you are getting confused between the GPIO PIN numbers and the physical pins of the IC. The GPIO PIN numbers are what you use in your code… these won’t change whether you use the Uno or the Atmega328 directly.

You just need to ensure when using the Atmega328 you connect your buttons and LEDs to the correct physical pins. On the Uno the labelling on the header refers to the GPIO numbers to make connecting easier.

I feel dumb, I still don't get it, could you tell me where I would connect button 4 if not on pin 6 on the atmega328. Isn't pin 6 on the atmega328 the physical pin to pin 4 on the UNO? Please give me some examples using my pins, sorry to be a pain.

Yes.. physical pin 6 is GPIO pin 4... but that doesn't mean you need to change your code - your code ALWAYS refers to the GPIO PIN number.

You just need to know that GPIO pin 4... is physical pin 6 on the ATMEGA328 when you are wiring your circuit. So you would connect your button to pin 6... but you still refer to it in the code as pin 4.

So these will stay the same...

Sometimes the chips get labelled like this so it is easier to figure out what physical pins relate to which GPIO pins.

Ok thanks I got it now, makes sense :slight_smile:

Usually with a vehicle electrical system, where accessories are grounded directly to the chassis, P channel mosfets are a better choice. However, these are slightly more difficult to use because they have to be configured as a high side switch requiring an additional NPN transistor or N channel mosfet.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.