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


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...



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(){

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


Nick Gammon


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...?



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