3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Weight Sensing Tote Bag

Step 4Coding

Coding
You can test the code throughout the sewing process, first by connecting petals with alligator clips to create the circuits, then with the fabric circuits themselves. You can download the code (Readinput.pde) or view a flow diagram of the program's logic (Flow diagram.jpeg). 

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(). 

« Previous StepDownload PDFView All StepsNext Step »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
1
Followers
1
Author:markaleung