Today I did a simple dice with LabDroid:

```
function getRandom(max) {
return 1+Math.floor(Math.random() * Math.floor(max))
}
let force = 0.0
let rolled = ""
while(true) {
const accel = $in(0)
force += Math.abs(accel.x) + Math.abs(accel.y)
if (force > 100.0) // Keep the dice on the floor
force = 90.0
else if (force > 30.0) {
force *= 0.6
rolled += getRandom(6) + " "
}
else if (force > 10) // The dice wiggles out
force *= 0.6
else {
if (rolled.length > 0) {
$log(rolled + "*" + getRandom(6) + "*")
rolled = ""
$sleep(1000) // Give the dice some time to cool down
}
force = 0.0
}
}
```

Still thinking about how I could share some example projects. Hackaday, Instructable, YouTube or Github?! :/

Any other recommendations? :D

## Discussions

## Become a Hackaday.io Member

Create an account to leave a comment. Already have an account? Log In.