Swag-o-meter: Student Feedback System, Carnival Style

by ajvdmeij in Circuits > Assistive Tech

3914 Views, 41 Favorites, 0 Comments

Swag-o-meter: Student Feedback System, Carnival Style

Swagometer demo
IMG_8526.jpg
IMG_8529.jpg
IMG_8527.jpg
IMG_8531.jpg
IMG_8533.jpg
IMG_8535.jpg

Update 2: I made a mini swag-o-meter that really works. Check the video in the last step.

Update: you can participate in a contest: invent a killer app for the swag-o-meter! Win a great prize! Click this sentence for more info!

As a physics teacher I give my students feedback every day. It is not more than fair that they can give me feedback as well. And of course they do. I try to build a safe environment in which they can talk freely.

One day, just before the summer break, when I was having a conversation with my 16 year old "HAVO 4" students, I made a joke that they liked and they told me "You got swag, sir!" They explained to me that that was a good thing and as a physicist I questioned them about the "quantity" Swag and how you could measure that. We decided we needed a swag meter or as it was soon called "swag-o-meter".

In the summer, I kinda forgot about it but the first lesson after the break my students asked me if I had already started on the swag-o-meter. I am an evangelist for Maker Education in The Netherlands, in fact at that moment I just had been given a generous grant from the government to try and get as many schools, teachers and students involved in Learning by Making so I felt I couldn't refuse. Besides that, I really wanted to do a complex and extensive project. So I told them I would try to make one, if they would help me design the perfect swag-o-meter.

I gave them the assignment to draw or write out a design. You can see their ideas (in Dutch) here. The idea converged to a system with two buttons. After each class, my students walk past these two buttons and choose "swag" or "no swag". When there are more than a certain amount of "swags" the system would flash a green light and play a joyous sound. If the class was boring and a lot of them pushed the "no swag" button, the system would flash a red light and play a disappointed song. The level of "swag" should be visible by up and down going lights. We (this swag-o-meter is made entirely in collaboration with Rolf van Oven, my friend and colleague) decided we would make a system that looked like and old fashioned, high striker. With only incandescent lights and the right colors and so on. Time to start!

I wrote this Instructable more like a report on how I build this thing than as an instruction. I hope you will find inspiration for your own things but I sure hope you will not make the exact same thing. Make it better and drop me a line if you did. And most of all: have fun!

If you want to have the original files for the lasercutter, just ask in the comments or you can send a tweet (see link).

Arjan van der Meij

The Design, Materials, Tools and Safety

swagometerontwerp.jpg
IMG_8567.jpg
IMG_8662.jpg
IMG_8684.jpg
IMG_8893.jpg
IMG_8703.jpg
IMG_9210.jpg
IMG_8704.jpg

We decided to make a high hitter kind of pole. My smallest class is 15 students and my largest 28. We thought it would be nice if it was not too easy and not too hard to reach the end level either way so we decided we would have 15 lights. One in the middle and seven up and seven down. We made our first list and started to order. This project was all about learning and teaching and one of the things I wanted to experience was the adventure of ordering in China. So we did.

The list below was not the list we made beforehand. We have searched and ordered three times in China and some things we bought in The Netherlands (or were at hand in our School Maker Space). The prices are indications. At AliExpress, the prices change every day.

Materials

Total costs around €270 ($300)

Tools

  • Laser cutter
  • Drill
  • Soldering iron
  • Computer (for Arduino coding and digital design)
  • Screwdriver
  • All kinds of pliers
  • Knifes, etc.
  • 3D printer
  • (percussion) drill

Safety

The light bulbs are powered by 230 V. Always be very careful with power leads.

ALWAYS MAKE SURE THAT THE SWAG-O-METER IS NOT PLUGGED IN WHEN YOU ARE TINKERING.

The High Hitter Pole

IMG_9344.jpg
IMG_9453.jpg
IMG_9331.jpg
IMG_9335.jpg
IMG_9336.jpg
IMG_9346.jpg
IMG_9349.jpg
IMG_9340.jpg
IMG_9350.jpg
IMG_9342.jpg
IMG_9462.jpg
IMG_9351.jpg
IMG_9455.jpg
IMG_9463.jpg
IMG_9465.jpg
IMG_9670.jpg

The first thing we made was the high hitter pole with the bulbs. For this we had two boards cut at the right size at our local Home Depot. We chose hardwood because we want it in the classroom for several years. We measured the places for the bulbs (about 10 cm apart) and drilled the holes for the bulb holders. We put them in and attached the electric wire. The assembled wires were numbered according to the place of the bulbs. We led an extra wire from the top to the assembly point. That one is going to power the revolving beacon light.

We made a design for the top and the bottom. There the revolving beacon lights were to be placed. Green on the top and red at the bottom. It took a while to put the holes for the screws exactly where they should be to get the light in the middle. Cardboard is great! You can make very cheap prototypes before you do the definitive cutting in far more expensive wood. After making the top and bottom pieces, the name was designed and cut out in wood. It is easy to replace this and I really hope that will be necessary one day. I hope one day the word "swag" will have passed and a new word will pop up that I have to put on top!

Making the Brains

circuit1.png
IMG_9515.jpg
IMG_9520.jpg
IMG_9521.jpg
IMG_9522.jpg
IMG_9524.jpg
IMG_9531.jpg
IMG_9645.jpg
IMG_9648.jpg
IMG_9636.jpg
IMG_9638.jpg
IMG_9532.jpg
IMG_9653.jpg
IMG_9658.jpg
circuit2.png
IMG_9003.jpg
IMG_2088.jpg

As a physics teacher I have to explain relay obviously. I always us the metaphor of making a connection between the sweet microprocessor world of lower voltages (5V) to the big mean world of real power (230V in The Netherlands). In my more than 20 year career I only explained it and never had to make use of one. Well that changed in one day. The same goes for the transistor.

We had to make a system for the large bulbs that need 230 V and a system for the 12V stuff. The most important 12V stuff that we want to switch are the small 12V bulbs that we want to use to light an arrow that points at the buttons. It will show an animation that will tempt the students to push one of the buttons. See the photo.

Rolf had already made some Arduino-light bulb combinations and explained that when all the relays were on, that the Arduino couldn't provide the necessary current. So the signal of the Arduino had to be amplified. Because of the fact that many the small light bulbs, the revolving beacons and the amplifier all work at 12 V we decided to use 12V relays.

The soldering had to be very precise. First I cut of the unnecessary pin of the relay. The I soldered a short thick, wire to the power pins and. I soldered the collector of the transistor to the coil of the relay, a 10K resistor to the base and a long wire (for the Arduino) to the resistor.

The power wires were screwed in the power blocks (the ends soldered for safety). I designed a wooden holder with CorelDraw and cut it with the laser cutter (three 3 mm plywood sheets and one underneath). Five relays in a row,fitting snugly in the holder. With the relays in place I connected the emitters of the transistors to each other. The other sides of the coil of the relay were connected to each other. On the last one I also soldered a long wired was to be connected to the 12V plus pole of the power supply.

The wires connected to the 10k resistors were soldered on pin headers. I made three wooden holders. Each holder consisted of five relays so I made a pin header that fits nicely on the short side of the Arduino Mega I used. Of course I used a lot of heat shrink to cover as much metal as I could. I think the system will not pass Dutch or American regulation demands but it is going to be put in a box that will be opened rarely if ever.

I repeated all of the above for the small light bulbs. Those are on 12V so I could use a shortcut. The 12V that goes to the really is also connected to the wire that get switched. Both have to be 12V. I also made 15 of these in three holders. Maybe a little too much but that gave us some room to decide how much small light bulbs we would like to use.

If you want to make a system like this, be sure to NEVER PLUG THE SYSTEM IN when you are soldering. The relay bank (see parts list) that I discovered after I had already soldered all this, are far more convenient but also a little dangerous because of the fact that the contacts of the live wires are on the back of the bank and can be touched. So if you want to use them, be sure to isolate the back. After I soldered all these wires I had to resolder quite a few transistors because after a few bends (trying to untangle the wires) the connections broke. That was a pity. But I love to solder so, whatever!

Later we all connected an IR receiver. Now we are able to communicate wirelessly with the swag-o-meter. We read the codes the remote control I normally use for my C-Touch monitor and used them for the swag-o-meter. That way I only have one remote control I have to use. Besides, the remote control that I got with the receiver had a very weak signal.

The Brainbox (aka the Head)

IMG_9838.jpg
IMG_9841.jpg
IMG_9844.jpg
IMG_9667.jpg
IMG_9846.jpg
IMG_9854.jpg
IMG_9855.jpg
IMG_0451.jpg
IMG_0929.jpg
IMG_0930.jpg

All the brain stuff has to be covered thoroughly. There is live wire that you don't want to touch and students are not always the most careful people so it has to be sturdy. Especially the power supply needs some room to cool down with its fan.

These things had to go in the box:

  • the power supply
  • six relay holders with relays each
  • the Arduino Mega
  • the amplifier and the soundboard
  • maybe the photon
  • all the wire (15 thick wires for the bulbs, 15 for the small bulbs in the arrow and numerous wires for the microprocessing bit.

On the outside of the box:

  • a key lock switch
  • a large hole for the wires from the bulbs and the revolving beacons
  • an USB B mount attached to the Arduino, to program it without having to open the box
  • an entrance for the power
  • an entrance for the wires to and from the large switches.

The layout of the inside of the box took me some time. I decided to make boxes in cardboard, the exact size of the components. I used Boxmaker to make the plans and cut them with our lasercutter. We decide to build a flat box without different levels and after some sliding we had a promising layout. The Arduino, as the center of the brains in the middel, the power on one side and the really holders gathered around the Arduino. I cut a cardboard layout and everything seemed to be placed alright (see the last photographs). So I cut a baseplate and a box around it and after three attempts it was OK.

The Pointing Arrow

IMG_8604.jpg
IMG_9003.jpg
IMG_1028.jpg
IMG_1031.jpg
IMG_1027.jpg
IMG_2144.jpg
IMG_2172.jpg

For my students it has to be a joy to give feedback to me. So we decided we needed a fun element which points the students to giving the thumbs up or thumbs down. We thought that a literal pointer, an arrow would be the best and Rolf made a prototype very quickly. The small light bulbs on either side of the arrow and an animation that slide toward the tip of the arrow immediately did the job.

It was a prototype so we discovered a few things we could do better. The bulbs were sticking out so they were vulnerable. Furthermore they became very hot, so it has to be out of reach for the students. But then it couldn't point at the buttons. What to do?

We searched for nice arrows and a Google Search with the words "light bulbs arrow" did the trick. Common features: a border and a red inside. So we decided to make just that. I did a quick calculation: we have fifteen relays to switch the 12 V devices. Two are for the light beacons, two for the LEDs inside the big buttons, so we have eleven left. The bulbs are very bright when connected to 12 V so we decided to put two in series. We then have 11 positions.

I drew an arrow in CorelDraw of about 30 cm (more would not fit). To cover the bulbs I chose a transparent plexiglass. The bulbs have to fit in a second layer and there has to be a bottom. So three layers and the sides. It took some time and two prototypes to make the final arrow. We put the lightbulbs in and lead the wires to the central processing unit. As easy as it is to write this down, so many difficulties we had doing it. We opted for a thick wire in the centre because of the large currents it would draw. But soldering such a heatsink is not very easy. But in the end we got it done with the help of a great student who is a master solderer.

I also 3D printed a golden SWAG sign to put inside the arrow. Carnival style!

It still has to be installed. The arrow isn't necessary obviously so we decided to focus on the main functions of the swagometer. I will show the arrow here when it is installed.

The Button Plate

IMG_8567.jpg
IMG_0934.jpg
Knoppen/buttons swagometer
IMG_0446.jpg

We looked for the largest buttons available and found the Big Dome Pushbuttons. Spark fun describes them as: "It's the end of the world, and you need a button to press. This is it." A sturdy microswitch and a 12V light inside which we were going to use to give feedback to the provider of the feedback.

Of course we put theme in a box which we made with the help of boxmaker. We programmed the Arduino to pause the buttons for a second to prevent multiple votes. It gives the feedback by blinking very fast. When the pause time is over, it goes back to a slow blink.

The Sound

boxen.jpg
IMG_2093.jpg
Schermafbeelding 2016-04-07 om 12.32.13.png
IMG_0350.jpg
Schermafbeelding 2016-04-07 om 12.27.34.png

We tried an mp3-shield for he Arduino but that didn't work out (something to do with the translation of the pins). So we decided to use an Adafruit Soundboard. That just works great. When you plug in the board it works like a USB disk. You can upload some sound files (in WAV or OGG format). Then when you detach the USB cable and switch a button, it can be used to play the sound. You have to shorten on of the ports and then it plays the sound with that number in the filename. The Arduino is very capable of shortening a port. The only thing we had to do is amplify the sound form the board and hooking up some cheap speaker (4 ohms). We ran into some problems with which one was the ground but when we figured out that mistake it worked great.

There are a few moments when we need a sound:

  • When "Full Swag" is reached. Cheers obviously.
  • When "Full Down" is reached. The a "Sad Trombone" is at order.
  • At the start. A warm welcome or something like that.
  • Maybe an instruction.We are thinking of some hacks/easter eggs (see code section).

Putting It All Together, Painting and Testing...

IMG_1346.jpg
IMG_1350.jpg
IMG_1354.jpg
IMG_1355.jpg
IMG_1357.jpg
IMG_1359.jpg
IMG_1361.jpg
Swagometer

Sometime you need external pressure to take the next step. First of all the end of the school year is near and the students of my "swagometer" class are almost taking their exams an will be gone then. Secondly the press got wind of our invention from Twitter and they didn't take no for an answer (see further for the story about the press). So we painted the pole and hooked put the lights to the Arduino, did some elementary programming and started testing. After getting rid of a few flaws it worked just fine. And it looked the world! Be sure to see our test runs with animations in the YouTube movie!

For the paint I did some research on the internet. When you search for carnivalesque pictures, photo's from fairs from the fifties you see that a lot of artifacts are painted red. So I decided to use red as the main color and bought some grey to act as a supporting color. We used a black treaded hose to put the wires in.

The hardware worked great and now we could jump to the next, very exciting step: coding!

Hanging the Swag-o-meter on the Wall

IMG_2097.jpg
IMG_2103.jpg
IMG_2108.jpg
IMG_2110.jpg
IMG_2113.jpg
IMG_2114.jpg
IMG_2115.jpg
IMG_2125.jpg
IMG_2127.jpg
IMG_2128.jpg
Swagometer: voor het eerst aan de muur

It was time to hang the swag-o-meter on the wall in my class room. We build it in another place sow e had to move the swagometer. That was quite a challenge! The pole and the brainbox and the loudspeakers and the voting buttons are alle connected so we had to walk very coordinated. In my class room we attached an anchor system on the back of the pole and on the wall with some heavy wall screws and plugs. The system was meant for hanging a mirror but we tweaked it (on top of the sticky back, we used screws) and it now is a system that is very sturdy and it is possible to detach it. Not that we want to do that very soon.

To be safe (after all it is used in a class room) we made a security system to prevent the pole from falling too easily on the floor. After hanging it up, we noticed some flaws. First of all the connection with the vacuum cleaner hose from swagometer to brainbox (that is on top of the cabinet) is too long and the connection from the voting buttons tot the brainbox is al little too short, but we managed. Secondly, we saw that if you hang it up like this, you also have to paint the bottom of the swag-o-meter.

But! It worked and it was great to see the first test runs on the spot where it was always meant to be!

The buttons were attached to the side of the cabinet by putting velcro on it. we put the hooks on the cabinet side and the loops on the button plate. Although they had a glue layer, we tacked on top of that to the cabinet. We also made a barrier around the box with the brains to prevent it from sliding of the top of the cabinet.

The Software

When we start the swagometer the following task should start:

  • First it performs some animations
  • Then it will be ready for the voting
  • It has to count up and down
  • If the count reaches the bottom or the top it should do an animation and put on the revolving beacons and play some sounds.
  • For fun we want to implement some other functionalities like a count down clock, a binary counter (215=32768), some jokes with sounds, a cheering animations for a great achievement of a student and maybe a game (we have a 15x1 pixel large screen).
  • Maybe later we can make some connections to the internet (no, not a scoreboard, open to all of you ;-)

At first we (Rolf is the experienced code writer) wrote a voting procedure and a starting animation. The countdown functionality wasn't very difficult too so we wrote that too. The IR remote procedures are more difficult. We have to find out how the interrupts work. For now it works moer or less and it is alway difficult to have the Arduino listen to the remote. We will dive into that later. I think the binary counting is very easy but we haven't tried that yet.

The code:

// IR moet nog beter<br>// in deze versie gebruiken we een functioe om de lampen aan te zetten: zetlamp(1,aan)= ...
//constanten
const int knopgroen = 6;      // Arduino pin 6  input green button
const int knoprood = 5;       // Arduino pin 5  input red button
const int geluidswag = 2;     // Arduino pin 2 if shorted: cheers
const int geluidgeenswag = 3; // Arduino pin 3 if shorted: sad sound
const int lampgroen = 24;     // Arduino pin 24 light in green button
const int lamprood = 26;      // Arduino pin 26 light in red button
const int zwaaigroen = 52;    // Arduino pin 52 green beacon
const int zwaairood = 50;     // Arduino pin 50 red beacon
const int aan = 1;            // variable to set the lights ON
const int uit = 0;            // variable to set the lights OFF
const int onvoldoende = 8;    // onvoldoende geluid trigger pin op de arduino, 9 en 10 zijn ook beschikbaar. 8 is sound board 5, 9 is 6, en 10 is 7.
// variabelen (startwaarden)
int swag = 8;                 // starting value swag half
int tel1 = 0;                 // counter for waiting: 20 times a delay cycle is both lights on and off
int aftelloopteller = 11;      // counter for loop in count down
int aftellampteller = 53;      // counter for which light is off in countdown
int wacht = 0;                // if this variable is 0 it is possible to vote, if 1, it is not possible (you g=have to wait
int klaar = 0;                // if this is 1, an end is reached (swag or non-swag and you have to use the remote to start again
int keuze = 0;                // choice for which mode: default = 0 = swagometer
int knipper = 0;              // counter: number of blinks before the next student is able to vote
//int start = 1;
#include          // load IR remote library
int RECV_PIN = 53;            // Arduino pin 53 input remote
IRrecv irrecv(RECV_PIN);      // IR remote listening mode
decode_results results;       // decode IR signal
void setup() { 
  for(int r=23; r<55; r++) {  // Arduino output pins for the 230 V lights
      pinMode(r, OUTPUT);
  } 
  pinMode(knopgroen, INPUT_PULLUP);  // Arduino input pin green button
  pinMode(knoprood, INPUT_PULLUP);   // Arduino input pin red button
  Serial.begin(9600);                // serial monitor for debugging
  pinMode(geluidswag, OUTPUT);       // set the sound pins to HIGH -> no sound
  digitalWrite(geluidswag, HIGH);    
  pinMode(geluidgeenswag, OUTPUT);   
  digitalWrite(geluidgeenswag, HIGH);   
  pinMode(onvoldoende, OUTPUT);      // some other sound
  digitalWrite(onvoldoende, HIGH);
  irrecv.enableIRIn();               // start IR receiver
  startanimatie1();
}
void loop() {
  leesIR();            // read IR
  switch (keuze) {
        case 0:
          klaar = 0;  //reset
          swag = 8;
          keuze=1;
          stem();
          break;
        case 1:       // voting
          stem();
          break;   
        case 2:
          telaf();    // count down
          break;
        case 3:
          allesuit(); // shut everything off
          break;
          
        case 6:
          bokma();    // play funny sound
          break;
          
        case 99:
          leesIR();
          delay(100);
          break;
    }
}
void leesIR(){   // IR codes are the codes that the remote of my c-touch screen sends out (read them in a seperate program)
    if (irrecv.decode(&results)) { // reset procedure
            Serial.println(results.value, DEC); // for debugging
            switch (results.value) {
                case 0x10EF2BD4:  // reset button of the remote
                  keuze=0;        // swagometer swag 8
                  break;
                case 0x10EF51AE:  // menu button of the remote
                  keuze=1;        // game 
                  break;
                case 0x10EF03FC:  // input button of the remote
                  keuze=2;        // count down
                  break;
                case 0x10EFEB14:  // on/off button of the remote
                  keuze = 3;      // standby
                  break;
                case 0x10EFC13E:  // vol+ button of the remote
                  keuze = 4;      // binary counting automatically
                  break;
                case 0x10EF619E:  // vol- knop
                  keuze = 5;      // binary counting by hand
                  break;
                case 0x10EF49B6:  // pijltje omhoog knop
                  keuze = 6;      // funny sound
                  break;             
            }              
     }
     irrecv.resume(); // Receive the next value
}
void stem() { // votingprocedure
    if(digitalRead(knopgroen) == LOW) {    // if the green button is pressed the swag counter increases by 1
        swag++; 
        digitalWrite(lampgroen, LOW); 
        digitalWrite(lamprood, LOW); 
        wacht = 1;
    }
    if(digitalRead(knoprood) == LOW) {     // if the red button is pressed the swag counter decreases by 1
        swag--; 
        digitalWrite(lampgroen, LOW); 
        digitalWrite(lamprood, LOW); 
        wacht = 1;
    }
    if (wacht == 0 ) {                     // slow blinking button lights to indicate you can vote
        if(tel1 > 10) {
            digitalWrite(lampgroen, HIGH); //green and red on and off at the same time
            digitalWrite(lamprood, HIGH); 
            tel1--;
        } 
        else if (tel1 > 0) {
            digitalWrite(lampgroen, LOW); 
            digitalWrite(lamprood, LOW); 
            tel1--;
        } 
        else {
          tel1 = 20;
        }
    }
    
    Serial.print("swag: "); // debugging
    Serial.println(swag);
    for (int t = 1; t < 16; t++) {
      zetlamp(t,uit);
    }
     if(swag > 8) { // show the score above the center
        for(int r = 8; r < (swag+1); r++) { // show the score above the center; lights on from the middel to swag
            zetlamp(r,aan);
        }
      }
      else { // show the score for below the center; lights from
        for(int r = 8; r > (swag-1); r--) {
            zetlamp(r,aan);
         }
       }
    
    delay(100); // delay to make everything work at the right pace
    
    if (swag == 15) { // full swag is reached
        for(int r = 8; r < 16; r++) { // all lights out to start the animation
            zetlamp(r,uit);
        } 
        delay(50);  
        for(int r = 8; r < 16; r++) { // animation light up from center to top
            zetlamp(r,aan);
            delay (100);
        } 
        digitalWrite(zwaaigroen, HIGH); // green beacon on
        digitalWrite(geluidswag, LOW);  // cheering sound on
        delay(300);                     // sound button sound board 1/3 sec low
        digitalWrite(geluidswag, HIGH); // sound off
        klaar = 1;                      // wait for a rest
        keuze = 99;
    } 
    else { // if not full swag
        digitalWrite(zwaaigroen, LOW); 
    }
    if (swag == 1) { // non swag is reached
        for(int r = 1; r < 16; r++) { // all lights out to start the animation 
            zetlamp(r,uit);
        } 
        delay(50);  
        for(int r = 8; r > 0; r--) { // animation light up from center to bottom
            zetlamp(r,aan);
            delay (100);
        } 
        digitalWrite(zwaairood, HIGH);      // red beacon on
        digitalWrite(geluidgeenswag, LOW);  // sad sound on
        delay(300);                         // sound button sound board 1/3 sec low
        digitalWrite(geluidgeenswag, HIGH); // sound off
        klaar = 1;                          // wait for a rest
        keuze = 99;
    } 
    else { // if not non swag
         digitalWrite(zwaairood, LOW);
    }
    if (wacht == 1) { // fast blinking button lights to show you can' vote for a second
        for(knipper = 0; knipper < 10; knipper++) { // prevents multiple votes
            digitalWrite(lampgroen, HIGH); 
            digitalWrite(lamprood, LOW); 
            delay(100); 
            digitalWrite(lampgroen, LOW); 
            digitalWrite(lamprood, HIGH); 
            delay(100);
         } 
         wacht = 0; 
     } 
}
void telaf() {
    for (int r = 1; r < 16; r++) {
      zetlamp(r,aan);
    }
    digitalWrite(zwaaigroen, HIGH);     // grean beacon on before the countdown starts
    if(digitalRead(knopgroen) == LOW) { // if the green button is the countdown starts
        aftelloopteller = 0;
        aftellampteller = 15;
    }
    if (aftellampteller != 15) {        // during countdown
        digitalWrite(zwaaigroen, LOW);  // green beacon off
        digitalWrite(lampgroen, HIGH);  // green button light on
        digitalWrite(lamprood, LOW);    // red button light off
    }
    aftelloopteller++;
    for (int q = 15; q > aftellampteller - 1; q--) {
        zetlamp(q,uit);
    }
    delay(100);
    if (aftelloopteller == 10){         // every second (10 times the dealy of 100 ms) one down. 
        aftellampteller--;
        aftelloopteller=0;
    }
    if (aftellampteller < 1) {
        digitalWrite(lampgroen, LOW);   // green button light off
        digitalWrite(lamprood, HIGH);   // red button light on
        digitalWrite(zwaairood, HIGH);  // red beacon on
        keuze = 99;                     // end: only check for IR to determine what next
    } 
}
void zetlamp(int nummer,int stand) {    // procedure to put the lights on; something like putlight(number,on)
  if ((nummer>0) && (nummer<16)) {      // translates the number to the pin number of the arduino.
    int poortnummer = 21+2*nummer;      // bottom light = light number 0 and top light is light number 15 (so the middel one is number 8)
    if (stand==0){
        digitalWrite(poortnummer, LOW);
    }
    if (stand==1){
      digitalWrite(poortnummer, HIGH);
    }
  }
}
void startanimatie() {   //starting animation 
  allesuit();
  for (int r = 15; r>0; r--) {
    zetlamp(r,aan);
    zetlamp(r+1,uit);
    delay(200-(15-r)*10);
  }
  for (int r = 2; r<11; r++) {
    zetlamp (r,aan);
    zetlamp (r-1,uit);
    delay(80+r*10);
  }
    for (int r = 10; r>0; r--) {
    zetlamp(r,aan);
    zetlamp(r+1,uit);
    delay(300-(15-r)*10);
  }
    for (int r = 2; r<9; r++) {
    zetlamp (r,aan);
    zetlamp (r-1,uit);
    delay(200+r*15);
  }
  delay(2000);
}
void allesuit() { //procedure to turn every light off
  for (int r = 1; r< 16; r++) { zetlamp(r,uit); }      // all lights out to start the animation 
  digitalWrite(zwaairood, LOW);
  digitalWrite(zwaaigroen, LOW);
  digitalWrite(lamprood, LOW);
  digitalWrite(lampgroen, LOW);
  delay(100);
}
        
void bokma() {  // fun sound
  digitalWrite(onvoldoende, LOW);
  delay(300);
  digitalWrite(onvoldoende, HIGH);
  
  keuze = 3;
}

Using the Swag-o-meter

It is very easy to use the swag-o-meter. When you power it up it starts with a short animation and in a few seconds the students are able to vote. It is located at the entrance/exit of my classroom and they are invited to cast their votes on the way out. The first few times that doesn't work very well, everybody wants to see if "full swag' or better, 'non-swag" is established. That brings about a "traffic jam" obviously.

I intend to use it for many different goals. It all depends on the question you ask. "Did this lesson have swag?" is just one of the possibilities. But maybe the question: "Did you learn anything new today?" is better. Or...

I will try out many questions next school year.

The Media

IMG_1414.jpg
IMG_1374.jpg
IMG_1372.jpg
IMG_1408.jpg
ad2artikel.jpg
ad2foto.jpg

Since a few years I am very dedicated to bring Making back in the Dutch schools. First at my own school but more and more on a national scale. I think, as a maker educator, you should be an example and so, when I make things I make sure I write about it on different platforms like Twitter, Facebook, blogs and so on.

In the beginning of April I posted some tweets about the almost finished swagometer and it got picked up by the press man of a school association. They asked me if I was willing to answer a few questions for their newsletter and I agreed of course.

That was the beginning of a cascade of media attention. A journalist of a national newspaper read the newsletter and asked if she could write an article. I consented and she sent a photographer and wrote the article which got promoted to the national section of the newspaper. After that some radioshows contacted me and I talked about it on the radio too.

My focus was always the making of the swagometer and learning as I went along. The focus of the articles and interviews was the feedback. The headline of the newspaper was: "Stupid teacher? Press the red button!" the comparison between this system and the voting systems on television was made (Idols, ... got Talent).

Of course there were a lot of nice reactions. But, obviously, there were also some not so nice reactions. Some fellow teachers, especially on Twitter, thought that I promoted the use of a swagometer in all classrooms across the Netherlands. Of course not! It was always meant for my classroom, for my students. To start the conversation about the quality of my lessons!

There were also some online reactions about me and my swagometer. Some friendly ("good idea") to hostile ("He (that's me) should be fired, right away!"). There was someone who thought it was a good idea to promote her own company that trains teachers in feedback, "but not in this crazy way!".

In the newspaper a lady, named Truus, wrote a furious letter about me trying to become popular and why I and others always wanted school te be "cool".

It got "news-upgraded" by the hour but when national radioshows started to call and wanted me in their show, I declined. It costed too much of my time which I want to dedicate to my students. I wrote a (Dutch) blog about this.

On Tuesday the fifth of July the children of the class that designed the swag-o-meter, had their graduation ceremony and so I had to plan to unveil it before that. I just managed to do so 45 minutes before the ceremony. All my students showed up in their best dresses and there was a local newspaper to cover the event. It was a great event! In my speech I told the students and the other persons who were there about the little media storm, about the history and the way I intended to use the swag-o-meter. I could also tell them that they scored great on the national exams. In fact they scored better than any other group I had before (for 20 years).

Then Romy "opened" the swag-o-meter by pushing the green button. I chose Romy because of the fact that she wants to be a physics teacher too. The future!

During this event the local press was also present and they wrote on their website about it (including a video) and the next day it also appeared in the newspaper.

And last but not least, the famous popular scientific magazine KIJK will also be covering the swag-o-meter. For me, that is a childhood dream. The KIJK was and is the magazine for geeky boys and girls. As I told the reporter I never imagined that I could be in that magazine. That was not something an normal person could hope for. And now it comes true!

Miscellaneous

Aftellen
IMG_2774.jpg
IMG_2775.jpg
IMG_2778.jpg
IMG_2801.jpg
havo5namen.jpg
  1. The count down clock works very nice. A student has 15 seconds to answer a question before the bottom is reached. You can see it an the video.
  2. At the opening of the swag-o-meter, 45 minutes before the graduation of my students, I told them they scored great on the national physics exam (percentile 99: meaning they belonged to the best 1% of all students in The Netherlands). I thought it would be nice if I gave them a present. So in the days before the event I made 24 small swag-o-meters. A green blinking LED, three white LEDs and a red button. I soldered the LEDs parallel and hooked tem up to a two AA batteries. I designed a swag-o-meter box, engraved it with the laser cutter (full swag, the name of the class and their own name) and glued it together. I handed it to them at the opening. They liked it a lot.
  3. I teach at this great school, De Populier in The Hague, for 21 years now. With about forty to fifty students who graduate each year I have already reached the "1000-former-students" milestone. At reunions I am always ashamed I forgot so many names. I wanted to do this properly, so I took a picture of the students, had them write down their names on a piece of paper, scanned this and engraved this on a piece of wood. That piece of wood is glued to the wall next to the button plate.

Addendum

Game on my mini swagometer

For testing purposes I made a working mini swagometer. I tried to replicate as much components as possible. But instead of sending a signal to a relais, it is send directly to a LED. I made a case with a lasercutter, bought another Arduino Mega and started soldering. It worked out quite good and now I can test all code on the table without having to hook up the real one!

The most important thing I wanted to make, was a game. Together with Rolf we worked on the code for a few hours and on Easter I had the time to finish it. Now it is working inside my mini swag-meter. I still have to test it on the big one.

New code:

// second version with the possibility to test with the mini swagometer.
// there is a variable to choose between the large one and the mini: ISKLEIN (0: small, 1: large)
// no IR on the mini so a variable to choose which function
// keuze=0: swagometer, default
// keuze=1: swagometer, back to the last score
// keuze=2: count down
// keuze=3: everything off
// keuze=4: binary counting automatically
// keuze=5: binary counting by hand 
// keuze=6: "allemaal onvoldoende"
// keuze=7: game
// IR code by ibterrupt not tested yet
// IR CODES: (my remote I use for my smart board
// uit      10EFEB14
// omhoog   10EF49B6
// links    10EFE916
// rechts   10EFF906
// benee    10EF1BE4
// OK       10EFD926
// input    10EF03FC
// menu     10EF51AE
// exit     10EF2BD4
// vol+     10EFC13E
// C        10EF6D92
// arc      10EF817E
// vol-     10EF619E
// mute     10EFFB04
// freeze   10EF1DE2
//constanten
const boolean ISKLEIN = true;   // ISKLEIN=true: mini swagometer, ISKLEIN=false: large swagometer
const int knopgroen = 6;        // Arduino pin 6  input green button
const int knoprood = 5;         // Arduino pin 5  input red button
const int geluidswag = 2;       // Arduino pin 2 if shorted: cheers
const int geluidgeenswag = 3;   // Arduino pin 3 if shorted: sad sound
const int lampgroen = 24;       // Arduino pin 24 light in green button
const int lamprood = 26;        // Arduino pin 26 light in red button
const int zwaaigroen = 52;      // Arduino pin 52 green beacon
const int zwaairood = 50;       // Arduino pin 50 red beacon
const int aan = 1;              // variable to set the lights ON
const int uit = 0;              // variable to set the lights OFF
const int onvoldoende = 8;      // onvoldoende geluid trigger pin op de arduino, 9 en 10 zijn ook beschikbaar. 8 is sound board 5, 9 is 6, en 10 is 7.
// variabelen (startwaarden)
// KEUZE KEUZE KEUZE
int keuze = 4;                  // choice for which mode: default = 0 = swagometer
// KEUZE KEUZE KEUZE
int swag = 8;                   // starting value swag half
int tel1 = 0;                   // counter for waiting: 20 times a delay cycle is both lights on and off
int aftelloopteller = 11;       // counter for loop in count down
int aftellampteller = 53;       // counter for which light is off in countdown
int wacht = 0;                  // if this variable is 0 it is possible to vote, if 1, it is not possible (you g=have to wait
int klaar = 0;                  // if this is 1, an end is reached (swag or non-swag and you have to use the remote to start again
int knipper = 0;                // counter: number of blinks before the next student is able to vote
int getal = 0;                  // number of the binary counter auto  
int getalhand=0;                // number of binary counter manual      
int startgame=0;                // if startgame=0 the gamestartaniation is played. When startgame=1 the game is played without the animation
// game variables
const int tempo = 20;           // master speed, time between frames: if this is 50 the "bal"takes between 0.05 and 1.00 sec to get to the next position
int snelheid = 10;              // speed of the ball, range 1-20, NB: more is slower
int locatie = 8;                // position of the ball, starting in the middel
int richting = -1;              // 1 is up, -1 is down, maybe random?
int gameteller = 0;             // counts to the next movement
int score1 = 0;                 // score of player one (red button player)
int score2 = 0;                 // score of player 2 (green button player)
const int gamezwaaitijd = 1000; // time the beacon is on after a win
#include            // load IR remote library
int RECV_PIN = 53;              // Arduino pin 53 input remote
IRrecv irrecv(RECV_PIN);        // IR remote listening mode
decode_results results;         // decode IR signal
void setup() { 
  for(int r=23; r<55; r++) {            // Arduino output pins for the 230 V lights (odd) and 12 V lights (even) and more
      pinMode(r, OUTPUT);               // 230 V: 23=bottom light, 25=next, ..., 51=last one
  }                                     // 12 V: 28=first, 30=next,..., 48=last
  pinMode(knopgroen, INPUT_PULLUP);     // Arduino input pin green button
  pinMode(knoprood, INPUT_PULLUP);      // Arduino input pin red button
  Serial.begin(9600);                   // serial monitor for debugging
  pinMode(geluidswag, OUTPUT);          // set the sound pins to HIGH -> no sound
  pinMode(geluidgeenswag, OUTPUT);
  
  if (!ISKLEIN) {                       // in the large swagometer the sound is played when the port goes from HIGH to LOW
    digitalWrite(geluidswag, HIGH); 
    digitalWrite(geluidgeenswag, HIGH);
  }
  else {
    digitalWrite(geluidswag, LOW);      // in the mini swagometer the sound is played when the port goes from LOW to HIGH
    digitalWrite(geluidgeenswag, LOW);
  }
  pinMode(onvoldoende, OUTPUT);
  digitalWrite(onvoldoende, HIGH);      // "onvoldoende" sound
  if (!ISKLEIN) {
    attachInterrupt(0,CHECK_IR,CHANGE); //interrupt poging
    irrecv.enableIRIn();                // Start the receiver
  }
  if (!ISKLEIN) {                       // for speed I only start with the main anination for the large one
    startanimatie2();
  }
}
void loop() {
switch (keuze) {      //choice code
  case 0:             //reset
    klaar = 0;        
    swag = 8;
    keuze=1;
    stem();
    break;
  case 1:             // vote
    stem();
    break; 
  case 2:
    telaf();          // count down
    break;
  case 3:             // everyhing off
    allesuit();
    break;
  case 4:             // binary counting automatically
    telbinairauto();
    break;  
  case 5:             // binary counting by hand
    telbinairhandmatig();
    break;
  case 6:             // "allemaal onvoldoende" sound
    bokma();
    break;
  case 7:             // game
    playgame();
          
/*        case 99:
          leesIR();
          delay(100);
          break; */
    }
}
void CHECK_IR(){      // IR check
  while(irrecv.decode(&results)){
      Serial.println(results.value, DEC); // for debugging
      switch (results.value) {
          case 0x10EF2BD4: // reset button
            keuze=0;       
            break;
          case 0x10EF51AE:  // menu button
            keuze=1;       
            break;
          case 0x10EF03FC:  // input button
            keuze=2;       
            break;
          case 0x10EFEB14:  // on/off button
            keuze = 3;      
            break;
          case 0x10EFC13E:  // vol+ button
            keuze = 4;      
            break;
          case 0x10EF619E:  // vol- button
            keuze = 5;      
            break;
          case 0x10EF49B6:  // arrow up
            keuze = 6;      
            break;   
      }
  irrecv.resume();
  }
}
// old IR code. I' keeping this if the new code doesn' work
/*void leesIR(){
    if (irrecv.decode(&results)) { // reset procedure
            Serial.println(results.value, DEC); // for debugging
            switch (results.value) {
                case 0x10EF2BD4: // reset knopje
                  keuze=0;        // swagometer met swag=8
                  break;
                case 0x10EF51AE:  // menu knop
                  keuze=1;        // spelletje
                  break;
                case 0x10EF03FC:  // input knop
                  keuze=2;        // afteller
                  break;
                case 0x10EFEB14:  // aan/uit knop
                  keuze = 3;      // standby
                  break;
                case 0x10EFC13E:  // vol+ knop
                  keuze = 4;      // binair optellen automatisch
                  break;
                case 0x10EF619E:  // vol- knop
                  keuze = 5;      // handmatig binair optellen
                  break;
                case 0x10EF49B6:  // pijltje omhoog knop
                  keuze = 6;      // allemaal een onvoldoende
                  break;
                
                  
            }              
     }
     irrecv.resume(); // Receive the next value
} */
void stem() {                               // votingprocedure
    if(digitalRead(knopgroen) == LOW) {     // if the green button is pressed the swag counter increases by 1
        swag++; 
        digitalWrite(lampgroen, LOW); 
        digitalWrite(lamprood, LOW); 
        wacht = 1;
    }
    if(digitalRead(knoprood) == LOW) {      // if the red button is pressed the swag counter decreases by 1
        swag--; 
        digitalWrite(lampgroen, LOW); 
        digitalWrite(lamprood, LOW); 
        wacht = 1;
    }
    if (wacht == 0 ) {                      // slow blinking button lights to indicate you can vote
        if(tel1 > 10) {
            digitalWrite(lampgroen, HIGH);  //green and red on and off at the same time
            digitalWrite(lamprood, HIGH); 
            tel1--;
        } 
        else if (tel1 > 0) {
            digitalWrite(lampgroen, LOW); 
            digitalWrite(lamprood, LOW); 
            tel1--;
        } 
        else {
          tel1 = 20;
        }
        for(int t = 0; t<12; t++) {           // arrow off
        zetpijl(t, uit);
    }
        if(tel1 > 18) {zetpijl(1, aan);}      // arrow animation
        else if(tel1 > 16) {zetpijl(2, aan);}
        else if(tel1 > 14) {zetpijl(3, aan);}
        else if(tel1 > 12) {zetpijl(4, aan);}
        else if(tel1 > 10) {zetpijl(5, aan);}
        else if(tel1 > 8) {zetpijl(6, aan);}
        else if(tel1 > 6) {zetpijl(7, aan);}
        else if(tel1 > 4) {zetpijl(8, aan);}
        else if(tel1 > 2) {zetpijl(9, aan);}
        else {zetpijl(10, aan); zetpijl(11, aan);}
        
    }
    for (int t = 1; t < 16; t++) {            // all light off
      zetlamp(t,uit);
    }
     if(swag > 8) {                           // show the score above the center
        for(int r = 8; r < (swag+1); r++) {   // show the score above the center; lights on from the middle to swag
            zetlamp(r,aan);
        }
      }
      else {                                  // show the score for below the center; lights from
        for(int r = 8; r > (swag-1); r--) {
            zetlamp(r,aan);
         }
       }
    
    delay(100);                               // delay to make everything work at the right pace
    
    if (swag == 15) {                         // full swag is reached MAYBE A NEW SUB VOID?
        for(int r = 8; r < 16; r++) {         // all lights out to start the animation
            zetlamp(r,uit);
        } 
        delay(50);  
        for(int r = 8; r < 16; r++) {         // animation light up from center to top
            zetlamp(r,aan);
            delay (100);
        } 
        zetzwaai(zwaaigroen,aan);
        //digitalWrite(zwaaigroen, HIGH);     // green beacon on
        if (!ISKLEIN) {
          digitalWrite(geluidswag, LOW);      // cheering sound on  
          delay(300);                         // sound button sound board 1/3 sec low     
          digitalWrite(geluidswag, HIGH);     // sound off  
        }
        else {
          playcheer();
        }
        klaar = 1;                            // wait for a rest
        // keuze = 99;
    } 
    else {                                    // if not full swag
      zetzwaai(zwaaigroen,uit);
        //digitalWrite(zwaaigroen, LOW); 
    }
    if (swag == 1) {                          // non swag is reached MAYBE A NEW SUB VOID?
        for(int r = 1; r < 16; r++) {         // all lights out to start the animation 
            zetlamp(r,uit);
        } 
        delay(50);  
        for(int r = 8; r > 0; r--) {          // animation light up from center to bottom
            zetlamp(r,aan);
            delay (100);
        } 
        zetzwaai(zwaairood, aan);             // red beacon on
        if (!ISKLEIN) {
          digitalWrite(geluidgeenswag, LOW);  // cheering sound on  
          delay(300);                         // sound button sound board 1/3 sec low     
          digitalWrite(geluidgeenswag, HIGH); // sound off  
        }
        else {
          playsadtrombone();
        }
        klaar = 1;                                          // wait for a rest
    } 
    else {                                                  // if not non swag
         digitalWrite(zwaairood, LOW);
    }
    if (wacht == 1) {                                       // fast blinking button lights to show you can' vote for a second
        for(int telleruit = 1; telleruit<12; telleruit++) { // turn off totl arrow
          zetpijl(telleruit,uit);
        }
        for(knipper = 0; knipper < 11; knipper++) {         // prevents multiple votes
            digitalWrite(lampgroen, HIGH); 
            digitalWrite(lamprood, LOW); 
            zetpijl(knipper+1,aan);                          // fill up arrow
            delay(100); 
            digitalWrite(lampgroen, LOW); 
            digitalWrite(lamprood, HIGH); 
            delay(100);
         } 
         wacht = 0; 
     } 
}
void telaf() {                            // aftelproccedure
    for (int r = 1; r < 16; r++) {
      zetlamp(r,aan);
    }
    zetzwaai(zwaaigroen,aan);
    //digitalWrite(zwaaigroen, HIGH);     // grean beacon on before the countdown starts
    if(digitalRead(knopgroen) == LOW) {   // if the green button is pressed, the countdown starts
        aftelloopteller = 0;
        aftellampteller = 15;
    }
    if (aftellampteller != 15) {          // during countdown
      zetzwaai(zwaaigroen,uit);
      //digitalWrite(zwaaigroen, LOW);    // green beacon off
      digitalWrite(lampgroen, HIGH);      // green button light on
      digitalWrite(lamprood, LOW);        // red button light off
    }
    aftelloopteller++;
    for (int q = 15; q > aftellampteller - 1; q--) {
        zetlamp(q,uit);
    }
    delay(100);
    if (aftelloopteller == 10){           // every second (10 times the delay of 100 ms) one down. 
        aftellampteller--;
        aftelloopteller=0;
    }
    if (aftellampteller < 1) {
        digitalWrite(lampgroen, LOW);     // green button light off
        digitalWrite(lamprood, HIGH);     // red button light on
        digitalWrite(zwaairood, HIGH);    // red beacon on
    } 
}
void zetlamp(int nummer,int stand) {      // translates number of the light to the number of the ports on the Arduino
    int poortnummer = 21+2*nummer;
    if (stand==0){
        digitalWrite(poortnummer, LOW);
    }
    if (stand==1){
      digitalWrite(poortnummer, HIGH);
    }
  }
void zetpijl(int nummer,int stand) {      // translates number of the arrows to the number of the ports on the Arduino
  if ((nummer>0) && (nummer<12)) {
    int poortnummer = 26+2*nummer;
    if (stand==0){
        digitalWrite(poortnummer, LOW);
    }
    if (stand==1){
      digitalWrite(poortnummer, HIGH);
    }
  }
}
void zetzwaai(int welke, int stand) {     // translates the beacon to the port on the Arduino
  if (stand==0) {
    digitalWrite(welke, LOW);
  }
  if (stand==1) {
    digitalWrite(welke, HIGH);
  }
}
void startanimatie2() {                   // starting animation: animates a falling ball. Is a bit old now...
  allesuit();
  for (int r = 15; r>0; r--) {
    zetlamp(r,aan);
    zetlamp(r+1,uit);
    delay(200-(15-r)*10);
  }
  for (int r = 2; r<11; r++) {
    zetlamp (r,aan);
    zetlamp (r-1,uit);
    delay(80+r*10);
  }
    for (int r = 10; r>0; r--) {
    zetlamp(r,aan);
    zetlamp(r+1,uit);
    delay(300-(15-r)*10);
  }
    for (int r = 2; r<9; r++) {
    zetlamp (r,aan);
    zetlamp (r-1,uit);
    delay(200+r*15);
  }
  delay(2000);
}
void allesuit() {                       // all lights, arrow lights, beacons and button LEDs off 
  for (int r = 1; r< 16; r++) { 
      zetlamp(r,uit); 
  }  
  for (int r = 1; r<12; r++) {
    zetpijl(r,uit);
  }
  zetzwaai(zwaairood,uit);
  zetzwaai(zwaaigroen,uit);
  digitalWrite(lamprood, LOW);
  digitalWrite(lampgroen, LOW);
}
void allelichtenaan() {                 // all lights on
    for(int r = 1; r <16; r++) {
    zetlamp(r,aan);
  } 
}
void allelichtenuit() {                 // all lights off
    for(int r = 1; r <16; r++) {
    zetlamp(r,uit);
  } 
}
        
void bokma() {                          // sound "allemaal onvoldoende"
  digitalWrite(onvoldoende, LOW);
  delay(300);
  digitalWrite(onvoldoende, HIGH);
  keuze = 3;
}
void telbinairauto() {                  // binary counting automatically
    getal=getal+1;
    for (int i=0; i<16; i++) {
      if (bitRead(getal,i)==1) {
        zetlamp(i,aan);
      }
      else {
        zetlamp(i,uit);
      }
    }
  delay(100);                            //speed of counting
  if (getal == pow(2,15)) {
    zetzwaai(zwaairood,aan);
    zetzwaai(zwaaigroen,aan);
    delay (5000);
    getal=0;
  }
}
void telbinairhandmatig() {
  if(digitalRead(knopgroen) == LOW) {   // if the green button is pressed the swag counter increases by 1
    getalhand++;
  }
  if(digitalRead(knoprood) == LOW) {    // if the red button is pressed the swag counter decreases by 1
     getalhand--; 
  }
  if (getalhand>=0) {
    for (int i=0; i<16; i++) {
      if (bitRead(getal,i)==1) {
        zetlamp(i,aan);
      }
      else {
        zetlamp(i,uit);
      }
    } 
  }
}
void playgame(){                        // the game
  if (startgame!=1){
    startanimationgame();               // game animation
  }
  if (score1==6) {                      // red wins
    roodwint();
  }
  if (score2==6) {                      // green wins
    groenwint();
  }
  for (int x=1; x11-score2;x--) {     
    zetpijl(x,aan);
  }
  
    if(gameteller > 0 ) {
      gameteller--; 
  } 
  else {
      locatie = locatie + richting; 
      gameteller = snelheid; 
  }
  if(locatie == 0) {                    // player 2 scores
      score2++; richting = -1;
      locatie = 7;
      snelheid = 20; 
      nuscoort(2);                      //score animation
  } 
  if(locatie == 16) {                   // player 1 scores
      score1++; 
      richting = 1; 
      locatie = 8; 
      snelheid = 20; 
      nuscoort(1);                       //score animation
  }
  if(digitalRead(knoprood) == LOW) {    // red button pushed
    if(locatie == 1) {
        richting = 1;
        snelheid = gameteller; 
        locatie = 2;
    } 
  }                                     // new speed is calculated: later = quicker
  if(digitalRead(knopgroen) == LOW) {
      if(locatie == 15) {
          richting = -1; 
          snelheid = gameteller; 
          locatie = 14;
      } 
  } 
  allelichtenuit();
  zetlamp(locatie,aan);
  
  delay(tempo);
}
void startanimationgame (){             // game animation
  for (int i=1; i<16; i++) {
    zetlamp(i,uit);
  }
  zetzwaai(zwaairood,uit);
  zetzwaai(zwaaigroen,uit);
  zetlamp(8,aan);
  delay(50);
  for (int j=1; j<8; j++){
    zetlamp(8+j,aan);
    zetlamp(8-j,aan);
    delay(50);
  }
  zetzwaai(zwaairood,aan);
  zetzwaai(zwaaigroen,aan);
  delay(50);
  for (int k=11; k>0; k--) {
    zetpijl(k,aan);
    delay(50);
  }
  for (int l=1; l<12; l++) {
    zetpijl(l,uit);
    delay(50);
  }
  zetzwaai(zwaairood,uit);
  zetzwaai(zwaaigroen,uit);
  delay(50);
  for (int m=0; m<7; m++) {
    zetlamp(15-m,uit);
    zetlamp(1+m,uit);
    delay(50);
  }
  for (int n=1; n<12; n++) {
    zetpijl(n,aan);
  }
  for (int p=1; p<12; p++) {
    zetpijl(p,uit);
    delay(500);
  }
  startgame=1;
}
void roodwint(){                      // animation and stuff if red wins
  allesuit();
  zetpijl(1,aan);
  zetpijl(2,aan);
  zetpijl(3,aan);
  delay(200);
  for (int x=8; x>0; x--) {
    zetlamp(x,aan);
    zetpijl(12-x,aan);
    delay(200);
  }
  zetzwaai(zwaaigroen,aan);
  zetzwaai(zwaairood,aan);
  digitalWrite(lamprood, HIGH);         // red button light on
  if(digitalRead(knopgroen) == LOW || digitalRead(knoprood) == LOW) {
    score2=0;
    score1=0;
    allesuit();
  }; 
  delay(2000);
}
void groenwint(){                       // animation and stuff if green wins
  allesuit();
  
  zetpijl(1,aan);
  zetpijl(2,aan);
  zetpijl(3,aan);
  delay(200);
  for (int x=8; x<16; x++) {
    zetlamp(x,aan);
    zetpijl(x-4,aan);
    delay(200);
  }
  zetzwaai(zwaaigroen,aan);
  digitalWrite(lampgroen, HIGH);        // green button light on
  if(digitalRead(knopgroen) == LOW || digitalRead(knoprood) == LOW) {
    score2=0;
    score1=0;
    allesuit();
  }; 
  Serial.print("Score 1= ");
  Serial.println(score1);
  Serial.print("Score 2= ");
  Serial.println(score2);  
  delay(2000);
}
void nuscoort(int wie) {                // score animation and stuff
  int welke=0;
  Serial.print("wie= ");
  Serial.println(wie);
  if (wie==1) {
    zetlamp(15,uit);
    zetzwaai(zwaaigroen,aan);
    digitalWrite(lamprood, HIGH);       // red button light on
  }
  if (wie==2) {
    zetzwaai(zwaairood,aan);
    zetlamp(1,uit);
    digitalWrite(lampgroen, HIGH);       // green button light on
  }
 // int welke = zwaaigroen;
  delay(gamezwaaitijd);
  zetzwaai(zwaaigroen,uit);
  delay(gamezwaaitijd);
  zetzwaai(zwaaigroen,aan);
  zetzwaai(zwaairood,aan);
  allelichtenaan();
  for(int x=1; x<8; x++) {
    delay(100);
    zetlamp(x,uit);
    zetlamp(16-x,uit);
  }
  for(int x=1; x<16; x++) {
    zetlamp(x,uit); // alles uit
  }   
    zetlamp(8,aan); 
  zetzwaai(zwaaigroen, uit);
  zetzwaai(zwaairood,uit);
  digitalWrite(lampgroen, LOW);         // green button light on
  digitalWrite(lamprood, LOW);          // red button light on
  delay(500);
  for (int n=1; n<12; n++) {
    zetpijl(n,aan);
  }
  for (int p=1; p<12; p++) {
    zetpijl(p,uit);
    delay(100);
  }
}
void playcheer() {                   // plays a cheering sound with a single tone loudspeaker in the mini swagometer
    digitalWrite(geluidswag, HIGH);  // cheering sound on
    delay(100);                      // sound button sound board 1/3 sec low
    digitalWrite(geluidswag, LOW);   // sound off
    delay(100);                      // sound button sound board 1/3 sec low
    digitalWrite(geluidswag, HIGH);  // cheering sound on
    delay(100);                      // sound button sound board 1/3 sec low
    digitalWrite(geluidswag, LOW);   // sound off
    delay(100);                      // sound button sound board 1/3 sec low
    digitalWrite(geluidswag, HIGH);  // cheering sound on
    delay(100);                      // sound button sound board 1/3 sec low
    digitalWrite(geluidswag, LOW);   // sound off
    delay(100);                      // sound button sound board 1/3 sec low
    digitalWrite(geluidswag, HIGH);  // cheering sound on
    delay(100);                      // sound button sound board 1/3 sec low
    digitalWrite(geluidswag, LOW);   // sound off
    delay(400);                      // sound button sound board 1/3 sec low
    digitalWrite(geluidswag, HIGH);  // cheering sound on
    delay(100);                      // sound button sound board 1/3 sec low
    digitalWrite(geluidswag, LOW);   // sound off
    delay(100);                      // sound button sound board 1/3 sec low
    digitalWrite(geluidswag, HIGH);  // cheering sound on
    delay(400);                      // sound button sound board 1/3 sec low
    digitalWrite(geluidswag, LOW);   // sound off
}
void playsadtrombone() {             // plays the sad trombone sound with a single tone loudspeaker in the mini swagometer
    digitalWrite(geluidswag, HIGH);  // cheering sound on
    delay(400);                      // sound button sound board 1/3 sec low
    digitalWrite(geluidswag, LOW);   // sound off
    delay(400);                      // sound button sound board 1/3 sec low
    digitalWrite(geluidswag, HIGH);  // cheering sound on
    delay(400);                      // sound button sound board 1/3 sec low
    digitalWrite(geluidswag, LOW);   // sound off
    delay(400);                      // sound button sound board 1/3 sec low
    digitalWrite(geluidswag, HIGH);  // cheering sound on
    delay(400);                      // sound button sound board 1/3 sec low
    digitalWrite(geluidswag, LOW);   // sound off
    delay(400);                      // sound button sound board 1/3 sec low
    digitalWrite(geluidswag, HIGH);  // cheering sound on
    delay(800);                      // sound button sound board 1/3 sec low
    digitalWrite(geluidswag, LOW);   // sound off
}
void doeniks(){                      // do nothing
  
}