Code für 3d-gedruckte Diamanten-E-Textiles-Sample

E-Textiles-Sample mit 3d-gedruckten Diamanten

Der Code steuert mehrere unter den Diamanten verborgene LEDs

Dieser Code dient als Steuerung für vier einzelne LEDs, die separat an vier unterschiedliche Pins des Adafruit Flora Boards angeschlossen sind. In unserem E-Textiles Workshop haben wir die vier LEDs mit kleinen, hohlen, 3d-gedruckten Diamanten aus transparentem PLA-Filament  bedeckt. Die Diamanten fungieren als Diffuser Panels für die LEDs.

Um den Code zu nutzen, öffne ein neues Fenster in der Arduino IDE. Lösche als nächsten den kompletten Inhalt dieses Fensters. Kopiere dann den unten stehenden Code und füge ihn in die Arduino IDE ein. Jetzt musst Du den Code nur noch auf Dein Adafruit Flora Board übertragen.

YouTube

Mit dem Laden des Videos akzeptieren Sie die Datenschutzerklärung von YouTube.
Mehr erfahren

Video laden

Code für 3d-gedruckte Diamanten-Sample

/*Settings:
Connect the Flora Board with a DATA-Cable!!!!
Board: choose Adafruit Flora
Programmer: „Arduino as ISP“ works fine
turn on the board with the onboard switch*/

/*You can use this sketch to randomly blink 4 leds
You can use it with our diamond swatch.*/

//You can modify this sketch:
//try to light up the leds for a longer time.
//program shorter breaks
//see if you can modify the code to randomly blink 5 leds
//try to blink more than one led at a time
//use this sketch with an RGB led

//variables
int led6 = 6; //led6 is the led connected to pin 6 of the Adafruit Flora board
int led10 = 10; //led10 is the led connected to pin 10 of the Adafruit Flora board and so on
int led12 = 12;
int led9 = 9;

// the setup routine runs once when you press reset:
void setup() {
// Initialize the leds as an outputs.
pinMode(led6, OUTPUT);
pinMode(led9, OUTPUT);
pinMode(led10, OUTPUT);
pinMode(led12, OUTPUT);
Serial.begin(9600); //This turns on the Serial monitor. This is only for checking the random values on screen!
}
// the loop routine runs over and over again forever:
void loop() {
int duration = random(0,1000);//We randomly generate values between 0 and 999.
//We will later turn on one of our leds for exactly this time.

//Randomly choose an led that will be turned on:
int led = random (0,4);//We have four leds and this function will generate the values 0, 1, 2, 3 but not 4!!!
int breaktime = random(0,500);//Randomly generate a value between 0 and 499

//print the randomly generated values onto the screen to check what these values are:
Serial.print(„Duration: „);
Serial.println(duration);
Serial.print(„LED-Pin Nr. „);
Serial.println(led);
Serial.print(„Breatime: „);
Serial.println(breaktime);
Serial.println(„——————————„);
delay(2000); //wait for 2 seconds while we read the values on the screen
//later we will take the delay out to make our program run smoothly


//we program a switch case based on the randomly generated value for our led-variable
switch (led){
case 0: digitalWrite(led6, HIGH);break;
case 1: digitalWrite(led9, HIGH);break;
case 2: digitalWrite(led10, HIGH);break;
case 3: digitalWrite(led12, HIGH);break;
}
delay(duration);//chosen led lights up for the time stored in the duration-vaariable

digitalWrite(led6, LOW); //turn off all LEDs for the time that we randomly generated for „breaktime“
digitalWrite(led9, LOW);
digitalWrite(led10, LOW);
digitalWrite(led12, LOW);
delay(breaktime);
}

Zurück zur Code-Übersicht: Code für E-Textiles Workshop Samples

Vorhang auf für das Robo­Theater

Als Puppenspielerin bin ich schon seit 2016 mit dem RoboTheater unterwegs und inszeniere spannende Robotergeschichten für Kinder.

Die beiden Roboter auf dem Foto kannst Du in Strom - Eine Robotergeschichte live erleben.

Klicke hier, um mehr über diese und meine anderen coolen Roboter-Puppentheater-Inszenierungen zu erfahren.