Close

Workshop opdrachten

De workshop opdrachten van het onderwerp Wearable Technology.

workshop
Opdracht 3C
void setup() {
  // initialize digital pin 13 as an output.
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(13, HIGH);
  delay(500);
  // turn the LED on (HIGH is the voltage level)
// wait for a second
  digitalWrite(13, LOW);
 // turn the LED off by making the voltage LOW
  delay(500);              // wait for a second
  digitalWrite(12, HIGH);
   delay(500);

  digitalWrite(12, LOW);  
  delay(500); 
}
Opdracht 3D
// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 13 as an output.
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(13, HIGH);
  delay(250);
  // turn the LED on (HIGH is the voltage level)
// wait for a second
  digitalWrite(13, LOW);
 // turn the LED off by making the voltage LOW
  delay(250);              // wait for a second
  digitalWrite(12, HIGH);
   delay(500);

  digitalWrite(12, LOW);  
  delay(500); 
}


Opdracht 4C en 4D
int redLed = 10;
int greenLed = 11;


// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 13 as an output.
  pinMode(redLed, OUTPUT);
  pinMode(greenLed, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
for (int helderheid=0; helderheid<256; helderheid++){
analogWrite(greenLed, helderheid);
delay(10);
}

for (int helderheid=0; helderheid<256; helderheid++){
analogWrite(redLed, helderheid);
delay(10);
}

for (int helderheid=255; helderheid>=0; helderheid--){
analogWrite(greenLed, helderheid);
delay(10);
}


for (int helderheid=255; helderheid>=0; helderheid--){
analogWrite(redLed, helderheid);
delay(10);
}
}


Opdracht 6B
float sensorWaarde = 0; // variabele aanmaken voor de sensorwaarde
float sensorWaardeGreen = 0;
int sensorPin =A0; // variabele aanmaken voor de sensorpin
int redLed = 10;
int greenLed = 11;

void setup(){
pinMode(sensorPin, INPUT);
serial.begin(960);

pinMode(redLed, OUTPUT);
pinMode(greenLed, OUTPUT);
}
void loop(){
sensorWaarde = analogRead(sensorPin); // lees de waardes die binnen komen
sensorWaarde = (sensorWaarde/1023)*255;
sensorWaardeGreem = (sensorWaarde)*-1;

analogWrite(redLed sensorWaarde);
analogWrite(greenLed, sensorWaardeGreen);

serial.printIn(sensorWaarde); // print sensorWaarde naar de seriele monitor
delay(200); // 5 keer per seconde wordt de waarde gestuurd.
}


Opdracht 7B
float sensorWaarde = 0; // variabele aanmaken voor de sensorwaarde
float sensorWaardeGreen = 0;
int sensorPin A0; // variabele aanmaken voor de sensorpin
int redLed = 10;
int greenLed = 11;

void setup() {
  pinMode(sensorPin, INPUT);
  Serial.begin(9600);

  pinMode(redLed, OUTPUT);
  pinMode(greenLed, OUTPUT);
}

void loop() {
  sensorWaarde = analogRead(sensorPin); //lees de waardes die binnen komen via sensorPin
  sensorWaarde = (sensorWaarde/700)*255;

  analogWrite(redLed, sensorWaarde);
  analogWrite(greenLed, sensorWaarde);

  Serial.println(sensorWaarde);
  delay(200);
}