Using Accelerometer outputs to change a field colour
Posted: Fri Feb 26, 2021 9:23 am
Hi,
Over the last few days I've started to explore the Accelerometer on mobile with some initial success.
It then came into my head whether I could use the outputs of the Accelerometer to change, I guess somewhat randomly, the background colour of a field as the phone moved so put together this code (which of course didn't work and I can't understand why?!)
I'm not understanding why it doesn't work!
Regards,
Glenn
Over the last few days I've started to explore the Accelerometer on mobile with some initial success.
It then came into my head whether I could use the outputs of the Accelerometer to change, I guess somewhat randomly, the background colour of a field as the phone moved so put together this code (which of course didn't work and I can't understand why?!)
Code: Select all
on accelerationChanged pX, pY, pZ
-- just to display the values in a field for my interest (I rounded the values to try and calm the number changes visually) - this all works
put round(pX) into field"px"
put round(pY) into field"py"
put round(pZ) into field"pz"
-- I was hoping that this would populate variables...
put pX*25.5 into tR
put pY*25.5 into tG
put pZ*25.5 into tB
-- ...that would then give RGB values that the field"col" could then respond to - which doesn't work!
set the backcolor of field"col" to tR, tG, tB
end accelerationChanged
Regards,
Glenn