Coder Social home page Coder Social logo

dice_thrower_v2's Issues

Push Button

How can I interrupt the void loop() and to have it wait until the next push of the button?

dNum * 1000 + 4000 to ?

Right now you use dNum * 1000 + 4000 which is derived from d6 using 10000 possibilities, but it doesn't scale. d4 is 8000 possibilities and maybe it should be
dNum * 1000 + (dNum * 1000) * 0.66) )to have it accurately scale to 10000.

Don't forget though that 10000 was a somewhat arbitrary number when you first picked it.

ledOn() ?

A suggestion of @ggerritsen

write a function to replace
digitalWrite(ledMatrix[row][col], HIGH);

e.g.

void ledOn(int x)
{
digitalWrite(x, HIGH);
}

Add: Dn variable

Dn = D6 or D10 (n is 6 or 10)
Add a variable so someone just needs to input the Dn number and it wil work accordingly.

e.g.
int Dn = 6;
....
mapChange = map(num, 1, 10000, 1, Dn);

NB Don't forget to add additional if statements for 7,8,9.

What type of Code?

Which of the two ways should I go for?

you can write void four() in two ways:
1.
void four()
{
digitalWrite(ledMatrix[0][0], HIGH);
digitalWrite(ledMatrix[2][0], HIGH);
digitalWrite(ledMatrix[0][2], HIGH);
digitalWrite(ledMatrix[2][2], HIGH);
}

or

void four()
{
for (int row = 0; row < 3; row++)
{
if (row == 1)
{
continue;
}
digitalWrite(ledMatrix[row][0], HIGH);
digitalWrite(ledMatrix[row][2], HIGH);
}
}

To Learn From: Huge problem because of ;

I had a huge problem which would give me seemingly incorrect random numbers. The Serial Monitor numbers were correct, but the hardware would flash different (extra) numbers.
As said, first this seemed random, and I couldn't figure it out why 8 and 9 would show up on the hardware even though the dNum was set to a max of 6.
After a couple of hours I figured out that it wasn't a coding mistake as much as it was a typo.
The code in itself was okay, but I made two errors. One with eight(); and one with nine();
In both eight() and nine() the if-statement was terminated with a ;
e.g.
void loop()
{
bla bla bla
if (mapChange == 8); <-- it was this semi colon that made it ignore the if-statement
eight();

because it ignored the if-statement the eight(); and nine(); functions were run unconditionally every single time.

for further reference see
https://forum.arduino.cc/index.php?topic=54579.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.