Go Down

Topic: Help to Ping only every 5 sec, and also how to send digits to my 7-seg.display!? (Read 887 times) previous topic - next topic

iching79

AWOL: I know, I was just testing.. snipped the code from an old workfile.

PaulS: I have almost no skills with coding. I dont quite understand how I managed to make the code "semiwork" like it is now...
        The compiler said something, but I didn want to spend any more time on that issue because there maybe a much smarter way all together...

E

holmes4

Take a look at this bit of code. It will save you 600+ lines of code

Code: [Select]
int aNumber =27;
short firstDigit = 0;
short secondDigit =0;
void setup(){
Serial.begin(9600);
}

void loop(){
  Serial.print(" aNumber is ");
  Serial.println(aNumber);
 
  Serial.print("first digit is ");
  /* calc first digit as an int */
  firstDigit = aNumber/10;
  Serial.println(firstDigit);
 
  Serial.print("second digit is ");
  /* calc second digit as an int */
  secondDigit = aNumber - ((aNumber/10)*10);
  Serial.println(secondDigit);
  delay(10000);
 
}


Mark

Nick Gammon


iching79

Nick Gammon: I have a photoresistor connected, if there is low light, the display will dim, and when much light the display will brighten.
                    (The idea is that in much light I will need more brightness on the display to make it visible)

holmes4: This is exactly the kind of code im looking for! Though, I am not certain how to implement it with my 10-99 numbers..yet ;)

PaulS: I have changed "mySerial.print(0x76,BYTE);" with "mySerial.write(0x76);",
         but then I have to change the BYTE-command(or maybe omit it) with something else...
         If "BYTE" isnt allowed an longer, how do I make the display understand the first number from the second...?
         


     
E

AWOL

Quote
Nick Gammon: I have a photoresistor connected

The correct answer to Nick's question is "nothing", because you have a semicolon at the end of your "if"
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Go Up