Step 4Coding
The code consists of several distinct parts.
The variable declarations declare variables for the Lilypad petals, an array and reading variables for measuring the force, variables to control the LED pulsing, and a variable to keep track of excessive pressure.
setup() activates all the pins, and enables Serial (for debugging).
loop() checks the pressure, logs excessive pressure, and either issues a warning if there is excessive force, shows the level if the switch is pressed, or pulsates otherwise. It also calls printReading().
getReading() uses an array to record the pressure.
printReading() helps with debugging, by printing all the reading variables.
checkWarning() logs a continuous period of high force before triggering warning().
warning() causes the LEDs to blink.
level() shows more LEDs for larger force.
pulse() shows faster pulsations for larger force.
ledLight() helps light the LEDs for level() and pulse().
ReadInput.pde4 KB| « Previous Step | Download PDFView All Steps | Next Step » |
![]() |
Add Comment
|








































