i'm new arduino , finished first project. idea have display shows total water usage of day. water usage measured in homeseer , sent via udp arduino mega board (and ethernet shield).
after trial , error , of people homeseer board works great, except 1 thing.
the last figure of led display doesn't display middle led (one of 7 segments). when program other arduino codes (like counter), led display correctly.
does know cause of problem?
my code is:
after trial , error , of people homeseer board works great, except 1 thing.
the last figure of led display doesn't display middle led (one of 7 segments). when program other arduino codes (like counter), led display correctly.
does know cause of problem?
my code is:
code: [select]
const int ledclockpin = 10;
const int leddatapin = 9;
const int ledlatchpin = 3;
char bitsent = 'lsbfirst';
int numbers[11] = {126, 12, 182, 158, 204, 218, 250, 14, 254, 222, 0}; //0 turn off display
int nummer;
int dig1;
int dig2;
int dig3;
int dig4;
#include <spi.h>
#include <ethernet.h>
#include <ethernetudp.h>
byte mac[] = {
0xde, 0xad, 0xbe, 0xef, 0xfe, 0xed
};
ipaddress ip(192, 168, 178, 150);
unsigned int localport = 8888;
char packetbuffer[udp_tx_packet_max_size];
char replybuffer[] = "acknowledged";
ethernetudp udp;
void setup(){
ethernet.begin(mac, ip);
udp.begin(localport);
serial.begin(9600);
pinmode(ledlatchpin, output);//latch
pinmode(ledclockpin, output);//clock
pinmode(leddatapin, output);//data
digitalwrite(ledlatchpin, high);
serial.begin(9600);
}
void loop(){
int packetsize = udp.parsepacket();
udp.read(packetbuffer, udp_tx_packet_max_size);
serial.println(packetbuffer);
long nummer = atoi(packetbuffer);
dig1 = nummer / 1000;
nummer = nummer - (dig1*1000);
dig2 = nummer / 100;
nummer = nummer - (dig2*100);
dig3 = nummer / 10;
dig4 = nummer - (dig3*10);
digitalwrite(ledlatchpin, high);
shiftout(leddatapin, ledclockpin, bitsent, numbers[dig4]);
shiftout(leddatapin, ledclockpin, bitsent, numbers[dig3]);
shiftout(leddatapin, ledclockpin, bitsent, numbers[dig2]);
shiftout(leddatapin, ledclockpin, bitsent, numbers[dig1]);
digitalwrite(ledlatchpin, low);
delay(10000);
}
hi, these parts incorrect:
this part:
should be:
but can't see how these errors cause 1 segment on 1 digit not light...
that same segment lights on other digits when running sketch? , segments light other sketches?
i assume using 74xx595 shift registers drive each digit?
paul
code: [select]
char bitsent = 'lsbfirst'; <-- makes no sense, not needed
this part:
code: [select]
shiftout(leddatapin, ledclockpin, bitsent, numbers[dig4]);
shiftout(leddatapin, ledclockpin, bitsent, numbers[dig3]);
shiftout(leddatapin, ledclockpin, bitsent, numbers[dig2]);
shiftout(leddatapin, ledclockpin, bitsent, numbers[dig1]);
should be:
code: [select]
shiftout(leddatapin, ledclockpin, lsbfirst, numbers[dig4]);
shiftout(leddatapin, ledclockpin, lsbfirst, numbers[dig3]);
shiftout(leddatapin, ledclockpin, lsbfirst, numbers[dig2]);
shiftout(leddatapin, ledclockpin, lsbfirst, numbers[dig1]);
but can't see how these errors cause 1 segment on 1 digit not light...
that same segment lights on other digits when running sketch? , segments light other sketches?
i assume using 74xx595 shift registers drive each digit?
paul
Arduino Forum > Using Arduino > LEDs and Multiplexing > 7 segment display not displaying all segments
arduino
Comments
Post a Comment