Difference between revisions of "MedTechDIY20 Another Team"
From Hackteria Wiki
(→Backyard Brains) |
(→Backyard Brains) |
||
Line 17: | Line 17: | ||
− | Wir haben den Bausatz gemäss den Instructions auf der [https://backyardbrains.com Webseite] | + | Wir haben den Bausatz gemäss den Instructions auf der [https://backyardbrains.com Webseite] fertiggestellt. Danach haben wir den default code |
+ | |||
+ | |||
+ | #define NUM_LED 6 //sets the maximum numbers of LEDs | ||
+ | #define MAX 150 //maximum posible reading. TWEAK THIS VALUE!! | ||
+ | int reading[10]; | ||
+ | int finalReading; | ||
+ | byte litLeds = 0; | ||
+ | byte multiplier = 1; | ||
+ | byte leds[] = {8, 9, 10, 11, 12, 13}; | ||
+ | |||
+ | void setup(){ | ||
+ | Serial.begin(9600); //begin serial communications | ||
+ | for(int i = 0; i < NUM_LED; i++){ //initialize LEDs as outputs | ||
+ | pinMode(leds[i], OUTPUT); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | void loop(){ | ||
+ | for(int i = 0; i < 10; i++){ //take ten readings in ~0.02 seconds | ||
+ | reading[i] = analogRead(A0) * multiplier; | ||
+ | delay(2); | ||
+ | } | ||
+ | for(int i = 0; i < 10; i++){ //average the ten readings | ||
+ | finalReading += reading[i]; | ||
+ | } | ||
+ | finalReading /= 10; | ||
+ | for(int j = 0; j < NUM_LED; j++){ //write all LEDs low | ||
+ | digitalWrite(leds[j], LOW); | ||
+ | } | ||
+ | Serial.println(finalReading); | ||
+ | //Serial.print("\t"); | ||
+ | finalReading = constrain(finalReading, 0, MAX); | ||
+ | litLeds = map(finalReading, 0, MAX, 0, NUM_LED); | ||
+ | //Serial.println(litLeds); | ||
+ | for(int k = 0; k < litLeds; k++){ | ||
+ | digitalWrite(leds[k], HIGH); | ||
+ | } | ||
+ | //for serial debugging, uncomment the next two lines. | ||
+ | //Serial.println(finalReading); | ||
+ | //delay(100); | ||
+ | } | ||
+ | |||
+ | |||
[[File:serialplot_anotherteam_pic1.png|400px]] | [[File:serialplot_anotherteam_pic1.png|400px]] |
Revision as of 17:15, 3 February 2020
go back to Medizintechnik DIY
Abstract
Team
Another Team besteht aus den drei Studierenden Claude Portmann, Simon Schmitter und Louis Schibli der Hochschule Luzern. Im Rahmen der Blockwoche DIY Medizintechnik formierte sich das Team, um interaktiv an den grossen Problemen unserer Zeit zu arbeiten. Aufgrund der Interdisziplinarität des Teams (Simon und Claude studieren Maschinentechnik, Louis studiert Medizintechnik) sind bis Ende der Woche bahnbrechende Lösungen zu erwarten.
Einleitung
Inputs
Experiments
Backyard Brains
Wir haben den Bausatz gemäss den Instructions auf der Webseite fertiggestellt. Danach haben wir den default code
- define NUM_LED 6 //sets the maximum numbers of LEDs
- define MAX 150 //maximum posible reading. TWEAK THIS VALUE!!
int reading[10]; int finalReading; byte litLeds = 0; byte multiplier = 1; byte leds[] = {8, 9, 10, 11, 12, 13};
void setup(){
Serial.begin(9600); //begin serial communications for(int i = 0; i < NUM_LED; i++){ //initialize LEDs as outputs pinMode(leds[i], OUTPUT); }
}
void loop(){
for(int i = 0; i < 10; i++){ //take ten readings in ~0.02 seconds reading[i] = analogRead(A0) * multiplier; delay(2); } for(int i = 0; i < 10; i++){ //average the ten readings finalReading += reading[i]; } finalReading /= 10; for(int j = 0; j < NUM_LED; j++){ //write all LEDs low digitalWrite(leds[j], LOW); } Serial.println(finalReading); //Serial.print("\t"); finalReading = constrain(finalReading, 0, MAX); litLeds = map(finalReading, 0, MAX, 0, NUM_LED); //Serial.println(litLeds); for(int k = 0; k < litLeds; k++){ digitalWrite(leds[k], HIGH); } //for serial debugging, uncomment the next two lines. //Serial.println(finalReading); //delay(100);
}