button press causing system reset

ok so I've been working on an electric fan controller for my brother truck and its coming along pretty well, I built a test circuit on a bread board and it seemed to work fine, however, when I built it on a proto board it is acting differently. I've double and triple checked every thing for circuit correctness.

my problem is with my gauge shift button. idea is to normally display one analogRead and when button is pressed, display the other analogRead......when i push the button on my final build it seems to be removing power from my project, its almost acting like a reset button.

im curious to why its acting different from breadboard to real life.

code and diagram are posted

/*************************************************** 
  This is a library for our I2C LED Backpacks

  Designed specifically to work with the Adafruit LED 7-Segment backpacks 
  ----> http://www.adafruit.com/products/881
  ----> http://www.adafruit.com/products/880
  ----> http://www.adafruit.com/products/879
  ----> http://www.adafruit.com/products/878

  These displays use I2C to communicate, 2 pins are required to 
  interface. There are multiple selectable I2C addresses. For backpacks
  with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks
  with 3 Address Select pins: 0x70 thru 0x77

  Adafruit invests time and resources providing this open source code, 
  please support Adafruit and open-source hardware by purchasing 
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.  
  BSD license, all text above must be included in any redistribution
 ****************************************************/
int tempSensor = A2;
int battSensor = A0;
const byte fanA = 7;
const byte fanB = 8;
const byte battTestSwitch = 4;
int tempSensorV;
float realTemp;
int battVolts;

#include <Adafruit_GFX.h>
#include <Adafruit_SPITFT.h>
#include <Adafruit_SPITFT_Macros.h>
#include <gfxfont.h>
#include <Wire.h> // Enable this line if using Arduino Uno, Mega, etc.
#include "Adafruit_LEDBackpack.h"

Adafruit_7segment matrix = Adafruit_7segment();

void setup() {
  pinMode(fanA,OUTPUT);
  pinMode(fanB,OUTPUT); 
  pinMode(battTestSwitch,INPUT_PULLUP);

  /*
#ifndef __AVR_ATtiny85__
  Serial.begin(9600);
  Serial.println("7 Segment Backpack Test");
#endif
  matrix.begin(0x70);
  */

    // print a hex number
  matrix.print(0xA55, HEX);
  matrix.writeDisplay();
  delay(500);

    // print a hex number
   matrix.print(0x01E, HEX);
  matrix.writeDisplay();
  delay(500);

  digitalWrite(fanA,LOW);
  digitalWrite(fanB,LOW);  
}

void loop() {
  tempSensorV = analogRead(tempSensor);
  //realTemp = math 

 // battVolts = analogRead(battSensor);
  battVolts = analogRead(battSensor/1023);


  if (digitalRead (battTestSwitch) == LOW){
      // print a floating point 
       matrix.print(battVolts);
       matrix.writeDisplay();
       delay(3000); 
  }
  else {
      matrix.print(realTemp);
      matrix.writeDisplay();
      delay(1000);
  }

  if (realTemp > 185 ){
    digitalWrite(fanA,HIGH);   
  }
  else {
    digitalWrite(fanA,LOW);
    digitalWrite(fanB,LOW);
  }
  if (realTemp > 215){
    digitalWrite(fanA,HIGH);
    digitalWrite(fanB,HIGH);
  }
  else {
    digitalWrite(fanA,LOW);
    digitalWrite(fanB,LOW);
  }
  
 /* 


  // print a hex number
  matrix.print(0xBEEF, HEX);
  matrix.writeDisplay();
  delay(500);

  // method #2 - draw each digit
  uint16_t blinkcounter = 0;
  boolean drawDots = false;
  for (uint16_t counter = 0; counter < 9999; counter ++) {
    matrix.writeDigitNum(0, (counter / 1000), drawDots);
    matrix.writeDigitNum(1, (counter / 100) % 10, drawDots);
    matrix.drawColon(drawDots);
    matrix.writeDigitNum(3, (counter / 10) % 10, drawDots);
    matrix.writeDigitNum(4, counter % 10, drawDots);
   
    blinkcounter+=50;
    if (blinkcounter < 500) {
      drawDots = false;
    } else if (blinkcounter < 1000) {
      drawDots = true;
    } else {
      blinkcounter = 0;
    }
    matrix.writeDisplay();
    delay(10);
    
  } */

}

This sort of thing is common with beginners and what you are doing is miss wiring the switches so that you short out the power supply when you push the button.
They should be wires from input to ground and have the internal pull up resistor enabled.

Power the circuit down, connect your DMM, set to Ohms, from 5V to ground, what is the resistance difference when the button is pressed v not pressed?

Grumpy_Mike:
This sort of thing is common with beginners and what you are doing is miss wiring the switches so that you short out the power supply when you push the button.
They should be wires from input to ground and have the internal pull up resistor enabled.

@Grumpy Mike, I'm pretty sure all of that was done.

@ GroundFungus... from 5vdc (post Voltage regulator) to GRD when button depressed is roughly 5k ohms
when pressed it drops to 1.3ish ohms

ok so obviously there is the problem.... I guess I will work backwards and quadruple check this thing.

Hi,
OPs circuit.

The diagram could do with some pin labels and component names.

Tom.. :slight_smile:

1.3 Ohms is probably the DMM lead resistance so you are looking at a dead short. A tiny solder bridge will do that. Take an exacto knife and scrape between the solder connections to make sure there are no bridges.

If you made the circuit on strip board you can get tiny tracks of copper that you can miss when breaking a track.

Can you post a good close up picture of both sides of your circuit board.

I will do that after I get home from work today. I'm also having another issue with my display. Sometimes it turns on and sometimes it doesn't. Like I said, I'll be at work for about 10 hours. If there are any technical questions or other requests in relation to my project/issues please leave comments. Thank you

sometimes it turns on and sometimes it doesn't.

Is that in reference to the backlight or that the LCD will not display characters or both?

The display is an adafruit 0.56" 4x7 segment display with i2c backpack.

Designed specifically to work with the Adafruit LED 7-Segment backpacks

Pretty obvious. Sorry, my bad.

TomGeorge:
The diagram could do with some pin labels and component names.

Tom.. :slight_smile:

this information is in the "code in progress" that I posted.

in further news i found by button issue, there was half a C hair of wire from my 4pin touching a 5vdc sorce. (pic with the toothpick in it)
so, in fact, i was grounding the system..

below are some pictures and video of my project. the video is on breadboard. I have seen it work in the "realLife" build

Will SCL and SDA show as 5vdc on a standard DMM?? (asking for diagnostic purposes)

to connect my controller to the gauge/display i used a USB cable... a 5vdc sorce, SDA, SCL, and Pin4. i used chassis ground for the display and pin4 ground. like i said, I have seen it work it just isnt working all the time.

Hi,

to connect my controller to the gauge/display i used a USB cable... a 5vdc sorce, SDA, SCL, and Pin4. i used chassis ground for the display and pin4 ground. like i said, I have seen it work it just isnt working all the time.

How long is the run from controller to display, I2C is only meant for short distances on PCBs, not as a major comms transmission system.

Tom... :slight_smile:

TomGeorge:
Hi,

How long is the run from controller to display, I2C is only meant for short distances on PCBs, not as a major comms transmission system.

Tom... :slight_smile:

3 feet... in the "general electronic" section I posted a question about i2c and what cable's would be suitable at what distances. most people said that 3 feet was an acceptable distance.

do you think if that were the issue it would cause intermittent problems with a display?

3 ft is on the long side for I2C. It may help to reduce the value of the pull ups on SDA and SCL. About 1K is the minimum. Also lowering the I2C data rate can help if the lower pull ups do not fix it.

I changed the resistors, still nothing. would I set the clock in setup??

Are you sure that the display is getting good 5V power and has a good ground connection back to the Arduino? Time to break out the DMM again.

DMM shows 4.86vdc where it should be

Hi,

Can you please post a copy of your complete circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

What is the relay module.

Do you have back EMF diodes on the fans?

Also.

this information is in the "code in progress" that I posted.

You should put ALL your connection information, INCLUDING relays in your schematic.

The number of times we ask for a schematic on a project that is very well advanced and the OP hasn't got one.
So we end up with a half hearted effort.

Have you got your button and I2C wires AWAY from the fan power and connection wiring?

Tom.... :o
PS. I'm not angry, just a little P*#*$ed off.

why does ground have to go back to the Arduino when the Arduino itself is hooked to 12vdc negative?

I've seen the display light up and function before when hooked up to 12vdc, using a 5vdc regulator of coarse. refer to the diagram. that's how its wired....in the drawing I did forget to add Arduino to ground but it is there in realLife

TomGeorge:
Hi,

Can you please post a copy of your complete circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

What is the relay module.

Do you have back EMF diodes on the fans?

Also.

You should put ALL your connection information, INCLUDING relays in your schematic.

The number of times we ask for a schematic on a project that is very well advanced and the OP hasn't got one.
So we end up with a half hearted effort.

Have you got your button and I2C wires AWAY from the fan power and connection wiring?

Tom.... :o
PS. I'm not angry, just a little P*#*$ed off.

sorry I do not have CAD so hand drawn is what you get. it is posted as an attachment.

parts list.

display: 0.56" 7-segment LED HT16K33 Backpack
controller: 5vdc proMini
voltage regulator: L7805CV
relay module: (no part number)

and my code

/*************************************************** 
  This is a library for our I2C LED Backpacks

  Designed specifically to work with the Adafruit LED 7-Segment backpacks 
  ----> http://www.adafruit.com/products/881
  ----> http://www.adafruit.com/products/880
  ----> http://www.adafruit.com/products/879
  ----> http://www.adafruit.com/products/878

  These displays use I2C to communicate, 2 pins are required to 
  interface. There are multiple selectable I2C addresses. For backpacks
  with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks
  with 3 Address Select pins: 0x70 thru 0x77

  Adafruit invests time and resources providing this open source code, 
  please support Adafruit and open-source hardware by purchasing 
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.  
  BSD license, all text above must be included in any redistribution
 ****************************************************/
int tempSensor = analogRead (A2);
int battSensor = analogRead (A0);
const byte fanA = 7;
const byte fanB = 8;
const byte battTestSwitch = 4;
int realTemp = 215.5;


#include <Adafruit_GFX.h>
#include <Adafruit_SPITFT.h>
#include <Adafruit_SPITFT_Macros.h>
#include <gfxfont.h>
#include <Wire.h> // Enable this line if using Arduino Uno, Mega, etc.
#include "Adafruit_LEDBackpack.h"

Adafruit_7segment matrix = Adafruit_7segment();

void setup() {
  pinMode(fanA,OUTPUT);
  pinMode(fanB,OUTPUT); 
  pinMode(battTestSwitch,INPUT_PULLUP);

Wire.setClock(100000);  
  
#ifndef __AVR_ATtiny85__
  Serial.begin(9600);
  Serial.println("7 Segment Backpack Test");
#endif
  matrix.begin(0x70);
  

    // print a hex number
  matrix.print(0xA55, HEX);
  matrix.writeDisplay();
  delay(800);

  digitalWrite(fanA,LOW);
  digitalWrite(fanB,LOW);  
}

void loop() {
  
 int tempSensor = analogRead(A2);
// int realTemp = 215.5, tempSensorV

  if (digitalRead (battTestSwitch) == LOW){

 // battVolts = analogRead(battSensor);
 int battSensor = analogRead (A0);
 float battVolts = battSensor * (5/1023);

 // print a hex number
  matrix.print(battVolts);
  matrix.writeDisplay();
  delay(3000); 
  }
  else {
      matrix.print(realTemp);
      matrix.writeDisplay();
      delay(1000);
  }

  if (realTemp > 185 ){
    digitalWrite(fanA,HIGH);   
  }
  else {
    digitalWrite(fanA,LOW);
    digitalWrite(fanB,LOW);
  }
  if (realTemp > 215){
    digitalWrite(fanA,HIGH);
    digitalWrite(fanB,HIGH);
  }
  else {
    digitalWrite(fanA,LOW);
    digitalWrite(fanB,LOW);
  }
}