Hi,
I want to add to my battery charger voltmeter. So voltmeter capable of measuring up to 30V using an Arduino board and a 4 Digit 7 Segment Serial LED Module - TM74HC595.
I really want some help, because it´s my school project and I don´t know how to start.
Well for a start the 74HCT595 is just a shift register - how does that drive your display?
As for the resistors, - well if this is a project you're meant to learn!..... Put two resistors in series, such that the same current flows through both of them... what's the voltage at the junction of the two? Ohms law is all you need.
To drive the analog input of an arduino values in the range of a few tens of thousand ohms would be fine.
They have also provided the a schematic for how the measured the voltage over two different batteries, using voltage dividers, but this might be somewhat unclear as it is far more than just the voltage divider on this schematic. They measure the voltage on A0 and A1 and the strange boxes are relays. Just ignore this schematic if it does not make sense to you.
// controls 4 digit 7 segment display
// test version 3
// 2015-05-02 by aarg
const byte numDigits = 4;
byte testDigit[numDigits];
// control pin definitions:
int shiftClock = 5;
int latchClock = 6;
int DIO = 7;
// count variables:
unsigned long previousMillis = 0; // will store last time of count
const long interval = 1000; // interval at which to count (milliseconds)
void setup ()
{
// configure outputs:
pinMode(shiftClock, OUTPUT);
pinMode(latchClock, OUTPUT);
pinMode(DIO, OUTPUT);
// initialize display buffer
for (int i = 0; i < numDigits; i++)
testDigit[i] = i;
}
void loop()
{
// update the display
//
displayUpdate(testDigit);
//
// any code in here that is non-blocking for more than the display
// refresh interval should not
// interfere with the display.
// see if it's time to increment the counter
//
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval)
{
previousMillis = currentMillis;
incrementDisplay();
}
}
// non-blocking display update
//
// every time this routine is called, 16 bits are shifted into the display
// and latched.
// The first 8 bits is the segment data, and first 4 bits of the second byte are
// the segment select.
void displayUpdate(byte displayDigit[])
{
static unsigned long lastDisplayUpdate;
const int scanRateHz = 60;
const int displayScanPeriod = 1000000L / numDigits / 8 / scanRateHz;
const byte segmentList[] =
{ // 0123456789AbCdEF-<space>
0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90, 0x8C, 0xBF, 0xC6, 0xA1, 0x86, 0xFF, 0xbf, 0x7f
};
static byte digit = 0;
static byte segment = 0x80;
if ((micros() - lastDisplayUpdate > displayScanPeriod))
{
// send segment data
for (byte i = 0x80; i >= 1; i = i >> 1)
{
if ( (i & segment) & ~segmentList[displayDigit[digit]])
{
digitalWrite(DIO, LOW);
}
else
{
digitalWrite(DIO, HIGH);
}
bitClock();
}
// send digit select data
for (byte i = 8; i > 0; i--)
{
if (i == digit + 1)
{
digitalWrite(DIO, HIGH);
}
else
{
digitalWrite(DIO, LOW);
}
bitClock();
}
// data is now in the display shift register, so latch to LEDs
//
latchData();
// increment variables to select the next segment and possibly the next digit:
//
segment = segment >> 1;
if (segment == 0)
{
segment = 0x80;
digit++;
if (digit >= numDigits)
digit = 0;
}
// reset timer for next update:
lastDisplayUpdate = micros();
}
// else just return without doing anything
}
void bitClock()
{
digitalWrite(shiftClock, LOW);
digitalWrite(shiftClock, HIGH);
}
void latchData()
{
digitalWrite(latchClock, LOW);
digitalWrite(latchClock, HIGH);
}
// very dumb counter (includes "-" and <space>)
//
void incrementDisplay()
{
if (++testDigit[0] > 17)
{
testDigit[0] = 0;
if (++testDigit[1] > 17)
{
testDigit[1] = 0;
if (++testDigit[2] > 17)
{
testDigit[2] = 0;
if (++testDigit[3] > 17)
{
testDigit[3] = 0;
}
}
}
}
}
Can somebody help me with the code. I already know how to control 74hc595 led tube modul, and I have code for analog (up to 5v measurment) voltmeter. But where do I have to put the voltmeter measurment to a code, that it´s shows it with the led tube modul?