Components and supplies
10 1k 1/4w resistor
10 Red LED 5mm
10 10k 1/4w resistor
10 Green LED 5mm
Arduino LilyPad USB
Project description
Code
Code snippet #1
arduino
1- /* Use your Arduino and your plug and wear accessories as a cool scale! Working principle: There are 2 LEDs (Green and Red): - the LEDs are both OFF with no load conditions; - the Green LED lights up with a weight between 100g and 2kg; - the LEDs are both ON with a weight between 2.1kg and 3kg; - the LEDs are blinking over 3kg BOM: Arduino lilypad Textile Analog Pressure Sensor Conductive wire 1x 10k resistor 2x 1k resistor 1x Green LED 1x Red LED Approximated reference table: 0g -> analogRead = 860 557g -> analogRead = 630 945g -> analogRead = 550 2121g -> analogRead = 410 4000g -> analogRead = 250 created by Arturo Guadalupi <a.guadalupi@arduino.cc> */ const int no = 850; const int ok = 530; const int mmh = 410; const int argh = 330; const int sensor = A0; const int greenLED = 5; const int redLED = 6; int analogVal; void setup() { // put your setup code here, to run once: pinMode(sensor, INPUT); pinMode(greenLED, OUTPUT); //green LED pinMode(redLED, OUTPUT); //red LED } void loop() { // put your main code here, to run repeatedly: analogVal = analogRead(A5); if (analogVal >= no) //no load { digitalWrite(greenLED, LOW); digitalWrite(redLED, LOW); } if (analogVal >= ok && analogVal < no) //100g < weight < 2kg; { digitalWrite(greenLED, HIGH); digitalWrite(redLED, LOW); } if (analogVal >= mmh && analogVal < ok) //2.1kg < weight < 3kg; { digitalWrite(greenLED, HIGH); digitalWrite(redLED, HIGH); } if (analogVal <= argh) //weight > 3kg; { digitalWrite(greenLED, HIGH); digitalWrite(redLED, HIGH); delay(150); digitalWrite(greenLED, LOW); digitalWrite(redLED, LOW); delay(150); }
Code snippet #1
arduino
1- 2 /* 3 Use your Arduino and your plug and wear accessories as a cool scale! 4 Working principle: 5 There are 2 LEDs (Green and Red): 6 - the LEDs are both OFF with no load conditions; 7 - the Green LED lights up with a weight between 100g and 2kg; 8 - the LEDs are both ON with a weight between 2.1kg and 3kg; 9 - the LEDs are blinking over 3kg 10 11 BOM: 12 Arduino lilypad 13 Textile Analog Pressure Sensor 14 Conductive wire 15 1x 10k resistor 16 2x 1k resistor 17 1x Green LED 18 1x Red LED 19 20 Approximated reference table: 21 0g -> analogRead = 860 22 557g -> analogRead = 630 23 945g -> analogRead = 550 24 2121g -> analogRead = 410 25 4000g -> analogRead = 250 26 27 created by Arturo Guadalupi <a.guadalupi@arduino.cc> 28 */ 29 const int no = 850; 30 const int ok = 530; 31 const int mmh = 410; 32 const int argh = 330; 33 const int sensor = A0; 34 const int greenLED = 5; 35 const int redLED = 6; 36 int analogVal; 37 38 void setup() { 39 // put your setup code here, to run once: 40 pinMode(sensor, INPUT); 41 pinMode(greenLED, OUTPUT); //green LED 42 pinMode(redLED, OUTPUT); //red LED 43 } 44 45 void loop() { 46 // put your main code here, to run repeatedly: 47 analogVal = analogRead(A5); 48 49 if (analogVal >= no) //no load 50 { 51 digitalWrite(greenLED, LOW); 52 digitalWrite(redLED, LOW); 53 } 54 55 if (analogVal >= ok && analogVal < no) //100g < weight < 2kg; 56 { 57 digitalWrite(greenLED, HIGH); 58 digitalWrite(redLED, LOW); 59 } 60 61 if (analogVal >= mmh && analogVal < ok) //2.1kg < weight < 3kg; 62 { 63 digitalWrite(greenLED, HIGH); 64 digitalWrite(redLED, HIGH); 65 } 66 67 if (analogVal <= argh) //weight > 3kg; 68 { 69 digitalWrite(greenLED, HIGH); 70 digitalWrite(redLED, HIGH); 71 delay(150); 72 digitalWrite(greenLED, LOW); 73 digitalWrite(redLED, LOW); 74 delay(150); 75 } 76 77
Downloadable files
untitled
untitled
Comments
Only logged in users can leave comments
Arduino_Scuola
0 Followers
•0 Projects
Table of contents
Intro
1
0