I am a beginner, but i have managed to develop a 2 digit seven segment display.
I am utilizing an external 12vdc power source, max7219, common anode digits, source driver and sink drivers.
I have been developing source code to scroll through 0 to 99. Unfortunately i go from 00 to 01 then i am out of the loop and nothing else happens. I have been through the arduino foundations, tutorials etc... . But I still can not figure out what I am doing wrong. Maybe somebody can lead me in the right direction to get this to work.
(I hope my code is posted correctly, my first time for posting).
I can set "v" to any value and it displays correctly.
Thank you in advance.
[quote]
#include [color=#006699]"LedControl.h"[/color]
[color=#CC6600]LedControl[/color] lc=[color=#CC6600]LedControl[/color](12,11,10,1);
[color=#CC6600]unsigned[/color] [color=#CC6600]long[/color] delaytime=200;[color=#7E7E7E]// v*75[/color]
[color=#CC6600]void[/color] [color=#CC6600][b]setup[/b][/color]() {
[color=#7E7E7E]/*[/color]
[color=#7E7E7E] The MAX72XX is in power-saving mode on startup,[/color]
[color=#7E7E7E] we have to do a wakeup call[/color]
[color=#7E7E7E] */[/color]
lc.[color=#CC6600]shutdown[/color](0,[color=#CC6600]false[/color]);
[color=#7E7E7E]/* Set the brightness to a medium values */[/color]
lc.[color=#CC6600]setIntensity[/color](0,8);
[color=#7E7E7E]/* and clear the display */[/color]
lc.[color=#CC6600]clearDisplay[/color](0);
[color=#CC6600]int[/color] v = 0;
}
[color=#CC6600]void[/color] [color=#CC6600][b]loop[/b][/color]()
[color=#7E7E7E]// function to send digits to 7 seg led[/color]
{
[color=#CC6600]for[/color]([color=#CC6600]int[/color] v=0;v<99;v++) {
[color=#CC6600]int[/color] ones;
[color=#CC6600]int[/color] tens;
[color=#CC6600]boolean[/color] zero;
[color=#CC6600]if[/color](v > 99)
[color=#CC6600]return[/color];
ones=v%10;
v=v/10;
tens=v%10;
v=v/10;
lc.[color=#CC6600]setDigit[/color](0,1,([color=#CC6600]byte[/color])tens,[color=#CC6600]false[/color]);
lc.[color=#CC6600]setDigit[/color](0,0,([color=#CC6600]byte[/color])ones,[color=#CC6600]false[/color]);
[color=#CC6600]delay[/color](3000);
}
}
[/quote]
sorry,
updated code posted correctly.
Did I say I am new to this.
#include "LedControl.h"
LedControl lc=LedControl(12,11,10,1);
unsigned long delaytime=200;// v*75
void setup() {
/*
The MAX72XX is in power-saving mode on startup,
we have to do a wakeup call
*/
lc.shutdown(0,false);
/* Set the brightness to a medium values */
lc.setIntensity(0,8);
/* and clear the display */
lc.clearDisplay(0);
int v = 0;
}
void loop()
// function to send digits to 7 seg led
{
for(int v=0;v<99;v++) {
int ones;
int tens;
boolean zero;
if(v > 99)
return;
ones=v%10;
v=v/10;
tens=v%10;
v=v/10;
lc.setDigit(0,1,(byte)tens,false);
lc.setDigit(0,0,(byte)ones,false);
delay(3000);
}
}
Thankor the response,
I made changes based on recommendations.
The same result, my digits scroll from "00" to "01" then stops.
They stay nicely lit but stop scrolling.
I have attached my updated code.
#include "LedControl.h"
LedControl lc=LedControl(12,11,10,1);
unsigned long delaytime=200;// v*75
void setup() {
/*
The MAX72XX is in power-saving mode on startup,
we have to do a wakeup call
*/
lc.shutdown(0,false);
/* Set the brightness to a medium values */
lc.setIntensity(0,15);
/* and clear the display */
lc.clearDisplay(0);
}
void loop() // function to send digits to 7 seg led
{
for(int v=0;v<100;v++) {
byte ones=v%10;
v=v/10;
byte tens=v%10;
v=v/10;
lc.setDigit(0,1,(byte)tens,false);
lc.setDigit(0,0,(byte)ones,false);
delay(3000);
}
}
What's this all about ?
The loop variable is v and you presumably want it its value to go from 0 to 99 but you change its value inside the for loop, not just once but twice. If you need the value of v/10 for some reason then put it in another variable to avoid messing with the operation of the for loop.