Hardware Reference
In-Depth Information
he other main point is the code that looks at the serial port to see if the Raspberry Pi has
sent any data back. You will see that all that happens is that variables are set, but these vari-
ables afect the program low later on, speciically in the sendData() function. his func-
tion converts the angles you measure from each pendulum into the distance to plot on the
screen. Using the simple sin rule of geometry shown in Figure 16-19, you can calculate the
distance from the centre of the swing.
Figure 16-19:
Generating a
displacement
from an angle.
he actual length of the pendulum is substituted by a value of half the number of pixels you
want to cover, and when you have two pendulums you use half that value and add them up.
In the sketch you will see that this is not quite the case with the values of the constant
Search WWH ::




Custom Search