---
title: "Beyond the SIK Guidebook: Digital Vote Counter"
description: Create a vote counter using only the parts found in the SparkFun Inventor's Kit v4.0. You'll be amazed at how many times you can use this throughout the school year with your students.
image: https://blog.sparkfuneducation.com/hubfs/FRIDAY_NEWSLETTER/2018/Sept_7_2018/SIK_Images-01.jpg
---

[![Sparkfun](https://www.sparkfuneducation.com/img/logo.png)](https://www.sparkfuneducation.com/index.html)

- [SparkFun Webstore](https://www.sparkfuneducation.com)
- [Higher Ed](https://sparkfuneducation.com/higher-ed/index.html)
- [Contact Us](https://www.sparkfuneducation.com/contact-us.html)
- [Follow Us](https://twitter.com/SparkFunEDU)

- [Home](https://www.sparkfuneducation.com)
- [Blog](https://blog.sparkfuneducation.com)
- [Curriculum](https://www.sparkfuneducation.com/curriculum.html)
- [PD/Events](https://www.sparkfuneducation.com/professional-dev.html)
- [KITS/Materials](https://www.sparkfuneducation.com/materials.html)
- [Educator Stories](https://www.sparkfuneducation.com/educator-stories.html)
- [Activities](https://activities.sparkfuneducation.com)

[Blog Home](https://blog.sparkfuneducation.com/) / [SIK](https://blog.sparkfuneducation.com/topic/sik) / Beyond the SIK Guidebook: Digital Vote Counter

<https://blog.sparkfuneducation.com/rss.xml>

# Beyond the SIK Guidebook: Digital Vote Counter

BY [Melissa Felderman](https://blog.sparkfuneducation.com/author/melissa-felderman) 9/13/18 6:27 AM

[0](https://blog.sparkfuneducation.com/beyond-the-sik-guidebook-digital-vote-counter#comments-listing)

[SIK](https://blog.sparkfuneducation.com/topic/sik)

![](https://blog.sparkfuneducation.com/hubfs/EDU/BLOG%20Images/Feldi-highres.jpg)

SparkFun's latest and greatest [SparkFun Inventor's Kit (v 4.0)](https://sparkfuneducation.com/products/sparkfun-inventors-kit.html) (SIK) is an incredible tool for educators to bring physical computing into the classroom. Many schools invest in this kit because it bundles together all the essential components needed to get started with Ardiuno AND it comes with an easy to follow beginners [guidebook](https://cdn.sparkfun.com/datasheets/Kits/SIK/SIK_v4_Book_Oct_25_FINAL.pdf). This guidebook can help beginner teachers and students navigate through the physical computing process and inspire project ideas. But what happens when you finish the guidebook and need more project inspiration? Fear not, because we have designed a project perfectly suited for the classroom exclusively using parts found in the SIK. This is a great challenge for your students and the final product can be used as a classroom tool throughout the year Introducing the Digital Vote Counter!

![SparkFun Inventor's Kit wiring for digital vote counter](https://blog.sparkfuneducation.com/hs-fs/hubfs/FRIDAY_NEWSLETTER/2018/Sept_7_2018/SIK_Images-01.jpg?width=600&name=SIK_Images-01.jpg)

Right now this just looks like a few buttons on a breadboard next to a RedBoard but I promise, there's more going on here. First let's take a look at the components. Pulling from the SIK, this project utilizes a [SparkFun RedBoard](https://www.sparkfun.com/products/13975), a [breadboard](https://www.sparkfun.com/products/12002), the [SparkFun Base Plate](https://www.sparkfun.com/products/11235), four [buttons](https://www.sparkfun.com/products/14460), four [330 ohm resistors](https://www.sparkfun.com/products/11507), the [USB cable](https://www.sparkfun.com/products/11301) and [jumper wires](https://www.sparkfun.com/products/8431). Each button has a unique color to differentiate it from the others: green, blue, red and yellow. These can symbolically signify an individual item or person to vote for. Each time a button is pressed, the 'vote count' for that color will grow by one. The tally will print on the Serial Monitor in the Arduino IDE.

## The Wiring

Now let's take a look at how these components come together for the vote counter.

 

![wiring diagram for SparkFun Inventor's Kit vote counter](https://blog.sparkfuneducation.com/hs-fs/hubfs/votecounter_bb.jpg?width=600&name=votecounter_bb.jpg)

 

The first thing we should always do when starting an Arduino project is to jump power and ground pins on the RedBoard or other microcontroller to the '+' and '-' tracks on the breadboard. This allows your components to easily access power and ground from anywhere on the breadboard.

As you can see in the circuit diagram above, each button has two leads that we will be working with, which are located on the left side of the well in the breadboard. One of the leads for each button should connect directly to power, which is demonstrated with a red jumper wire in the diagram.

The second lead is treated a little differently. First, the second lead needs to jump to an individual GPIO pin. Here we have Green -> Pin 2, Blue -> Pin 3, Red -> Pin 4, and Yellow -> Pin 5. That same lead that goes to the individual GPIO pin *also* needs to connect to ground via a resistor. This acts as a 'pull down resistor,' which is a resistor we use to help get a clean 'LOW' reading when the button is not pressed.

## The Code

Now that we've built our circuit it's time to write and upload our program. I have provided example code below with comments to demonstrate the function of each line.

```
//Vote Counter for by Melissa Felderman for SparkFun Electronics

//declaring the digital IO pin value for each button
int greenBut = 2;
int blueBut = 3;
int redBut = 4;
int yellowBut = 5;

//variable to hold button reading
int greenVal;
int blueVal;
int redVal;
int yellowVal;

//variable to hold the total vote count
int greenTotal = 0;
int blueTotal = 0;
int redTotal = 0;
int yellowTotal = 0;

//variables used in debounce functions to make sure on press = one vote
bool greenBool = false;
bool blueBool = false;
bool redBool = false;
bool yellowBool = false;
unsigned long lastDebounceTime = 0;
unsigned long debounceDelay = 200;

void setup() {
  //initiate the serial moniter
  Serial.begin(9600);

  //let Arduino know that the digital pins are recieveing input
  pinMode(greenBut, INPUT);
  pinMode(blueBut, INPUT);
  pinMode(redBut, INPUT);
  pinMode(yellowBut, INPUT);

}

void loop() {
  //read the value of the buttons and store them in a variable
  greenVal = digitalRead(greenBut);
  blueVal = digitalRead(blueBut);
  redVal = digitalRead(redBut);
  yellowVal = digitalRead(yellowBut);

  //if statements below allow us to press the button and get several HIGH readings with one press, but only register one vote per press
  if ((millis() - lastDebounceTime) > debounceDelay) {
    if ((greenVal == HIGH) && (greenBool == false)) {
      greenBool = true;
      greenTotal++;
      Serial.write(0);
      lastDebounceTime = millis();
    } greenBool = false;

    if ((blueVal == HIGH) && (blueBool == false)) {
      blueBool = true;
      blueTotal++;
      Serial.write(1);
      lastDebounceTime = millis();
    } blueBool = false;

    if ((redVal == HIGH) && (redBool == false)) {
      redBool = true;
      redTotal++;
      Serial.write(2);
      lastDebounceTime = millis();
    } redBool = false;

    if ((yellowVal == HIGH) && (yellowBool == false)) {
      yellowBool = true;
      yellowTotal++;
      Serial.write(3);
      lastDebounceTime = millis();
    } yellowBool = false;
  }

  //serial print commands to show results in the serial monitor
  Serial.print("Green: ");
  Serial.print(greenTotal);
  Serial.print(" ");
  Serial.print("Blue: ");
  Serial.print(blueTotal);
  Serial.print(" ");
  Serial.print("Red: ");
  Serial.print(redTotal);
  Serial.print(" ");
  Serial.print("Yellow: ");
  Serial.println(yellowTotal);

}
```

Once you have uploaded the program, you can open our serial monitor in Arduino and see the vote counts in real time!

![Arduino Serial Monitor showing vote counts](https://blog.sparkfuneducation.com/hs-fs/hubfs/Screen_Shot_2018-08-31_at_9.40.18_AM.png?width=482&name=Screen_Shot_2018-08-31_at_9.40.18_AM.png)

Let us know what you think about this classroom project in the comments below! 

- [Tweet](https://twitter.com/share)

### Subscribe to SparkFun Education Blog

### Topics

- [helpful information (79)](https://blog.sparkfuneducation.com/topic/helpful-information)
- [Maker Education (60)](https://blog.sparkfuneducation.com/topic/maker-education)
- [teaching tools (55)](https://blog.sparkfuneducation.com/topic/teaching-tools)
- [getting started (54)](https://blog.sparkfuneducation.com/topic/getting-started)
- [Guest Post (44)](https://blog.sparkfuneducation.com/topic/guest-post)
- [computer science (40)](https://blog.sparkfuneducation.com/topic/computer-science)
- [micro:bit (38)](https://blog.sparkfuneducation.com/topic/microbit)
- [student projects (37)](https://blog.sparkfuneducation.com/topic/student-projects)
- [STEM (36)](https://blog.sparkfuneducation.com/topic/stem)
- [programming (34)](https://blog.sparkfuneducation.com/topic/programming)
- [STEAM (31)](https://blog.sparkfuneducation.com/topic/steam)
- [Events (28)](https://blog.sparkfuneducation.com/topic/events)
- [Arduino (25)](https://blog.sparkfuneducation.com/topic/arduino)
- [robotics (20)](https://blog.sparkfuneducation.com/topic/robotics)
- [e-textiles (18)](https://blog.sparkfuneducation.com/topic/e-textiles)
- [Professional Development (17)](https://blog.sparkfuneducation.com/topic/professional-development)
- [basic circuits (17)](https://blog.sparkfuneducation.com/topic/basic-circuits)
- [What is a (16)](https://blog.sparkfuneducation.com/topic/what-is-a)
- [announcement (16)](https://blog.sparkfuneducation.com/topic/announcement)
- [makerspace (15)](https://blog.sparkfuneducation.com/topic/makerspace)
- [Community Partnership Program (14)](https://blog.sparkfuneducation.com/topic/community-partnership-program)
- [Training (13)](https://blog.sparkfuneducation.com/topic/training)
- [raspberry pi (13)](https://blog.sparkfuneducation.com/topic/raspberry-pi)
- [python (11)](https://blog.sparkfuneducation.com/topic/python)
- [AVC (10)](https://blog.sparkfuneducation.com/topic/avc)
- [paper circuits (10)](https://blog.sparkfuneducation.com/topic/paper-circuits)
- [Makey Makey (8)](https://blog.sparkfuneducation.com/topic/makey-makey)
- [SIK (8)](https://blog.sparkfuneducation.com/topic/sik)
- [Adventures in Science (7)](https://blog.sparkfuneducation.com/topic/adventures-in-science)
- [microcontroller (7)](https://blog.sparkfuneducation.com/topic/microcontroller)
- [Internet of Things (5)](https://blog.sparkfuneducation.com/topic/internet-of-things)
- [Processing (4)](https://blog.sparkfuneducation.com/topic/processing)
- [Javascript (3)](https://blog.sparkfuneducation.com/topic/javascript)
- [LilyPad (3)](https://blog.sparkfuneducation.com/topic/lilypad)
- [funding (3)](https://blog.sparkfuneducation.com/topic/funding)
- [weather (3)](https://blog.sparkfuneducation.com/topic/weather)
- [Insider (1)](https://blog.sparkfuneducation.com/topic/insider)
- [Johnny-five (1)](https://blog.sparkfuneducation.com/topic/johnny-five)

All Tags

### Recent Authors

- [Megan Hemmings (79)](https://blog.sparkfuneducation.com/author/megan-hemmings)
- [Maya Kleinbort (22)](https://blog.sparkfuneducation.com/author/maya-kleinbort)
- [Derek Runberg (21)](https://blog.sparkfuneducation.com/author/derek-runberg)
- [Shane Diller (16)](https://blog.sparkfuneducation.com/author/shane-diller)
- [Jeff Branson (15)](https://blog.sparkfuneducation.com/author/jeff-branson)
- [Angela Sheehan (12)](https://blog.sparkfuneducation.com/author/angela-sheehan)
- [Melissa Felderman (9)](https://blog.sparkfuneducation.com/author/melissa-felderman)
- [Megan Arnold (8)](https://blog.sparkfuneducation.com/author/megan-arnold)
- [Brian Huang (6)](https://blog.sparkfuneducation.com/author/brian-huang)
- [Shawn Hymel (6)](https://blog.sparkfuneducation.com/author/shawn-hymel)
- [Shelby Landsman (6)](https://blog.sparkfuneducation.com/author/shelby-landsman)
- [Jahnell Pereira (5)](https://blog.sparkfuneducation.com/author/jahnell-pereira)
- [Hailey Blessing (5)](https://blog.sparkfuneducation.com/author/hailey-blessing)
- [Mike Grusin (3)](https://blog.sparkfuneducation.com/author/mike-grusin)
- [Peter Hanson (3)](https://blog.sparkfuneducation.com/author/peter-hanson)
- [Andrew Milne (3)](https://blog.sparkfuneducation.com/author/andrew-milne)
- [Toni Klopfenstein (2)](https://blog.sparkfuneducation.com/author/toni-klopfenstein)
- [Joanna Drusin (1)](https://blog.sparkfuneducation.com/author/joanna-drusin)
- [Joe Romano (1)](https://blog.sparkfuneducation.com/author/joe-romano)
- [Mrinali P. Kesavadas (1)](https://blog.sparkfuneducation.com/author/mrinali-p-kesavadas)
- [Christa Flores (1)](https://blog.sparkfuneducation.com/author/christa-flores)
- [Michelle Shorter (1)](https://blog.sparkfuneducation.com/author/michelle-shorter)
- [Colleen Graves (1)](https://blog.sparkfuneducation.com/author/colleen-graves)
- [Janelle Curtis (1)](https://blog.sparkfuneducation.com/author/janelle-curtis)
- [Eric Bogatin (1)](https://blog.sparkfuneducation.com/author/eric-bogatin)
- [Athena Zhang Baker (1)](https://blog.sparkfuneducation.com/author/athena-zhang-baker)
- [Janice Levenhagen (1)](https://blog.sparkfuneducation.com/author/janice-levenhagen)
- [Carol Hamilton (1)](https://blog.sparkfuneducation.com/author/carol-hamilton)
- [Vanessa Lail (1)](https://blog.sparkfuneducation.com/author/vanessa-lail)
- [Bobby Chan (1)](https://blog.sparkfuneducation.com/author/bobby-chan)
- [Glenn Samala (1)](https://blog.sparkfuneducation.com/author/glenn-samala)
- [Zack Weaver (1)](https://blog.sparkfuneducation.com/author/zack-weaver)
- [Dr. Jean-Sébastien Blouin (1)](https://blog.sparkfuneducation.com/author/dr-jean-sébastien-blouin)
- [Daphne Sipes (1)](https://blog.sparkfuneducation.com/author/daphne-sipes)
- [Axel Reitzig (1)](https://blog.sparkfuneducation.com/author/axel-reitzig)
- [Justin Weisz (1)](https://blog.sparkfuneducation.com/author/justin-weisz)
- [Kylie Peppler (1)](https://blog.sparkfuneducation.com/author/kylie-peppler)
- [Michael Megliola (1)](https://blog.sparkfuneducation.com/author/michael-megliola)
- [Casey Kuhns (1)](https://blog.sparkfuneducation.com/author/casey-kuhns)
- [Rebecca Grabman (1)](https://blog.sparkfuneducation.com/author/rebecca-grabman)
- [Sylvia Martinez (1)](https://blog.sparkfuneducation.com/author/sylvia-martinez)
- [Charles Randolph (1)](https://blog.sparkfuneducation.com/author/charles-randolph)
- [Ira Sather-Olson (1)](https://blog.sparkfuneducation.com/author/ira-sather-olson)
- [Kathy Strickland (1)](https://blog.sparkfuneducation.com/author/kathy-strickland)
- [Pete Lewis (1)](https://blog.sparkfuneducation.com/author/pete-lewis)
- [Jamie Roth (1)](https://blog.sparkfuneducation.com/author/jamie-roth)
- [Mimi Tran Zambetti (1)](https://blog.sparkfuneducation.com/author/mimi-tran-zambetti)
- [Ryan Jenkins (1)](https://blog.sparkfuneducation.com/author/ryan-jenkins)
- [Kristen Deuschle (1)](https://blog.sparkfuneducation.com/author/kristen-deuschle)
- [Erika Myers (1)](https://blog.sparkfuneducation.com/author/erika-myers)
- [Sara Gonzalez (1)](https://blog.sparkfuneducation.com/author/sara-gonzalez)
- [Celeste Moreno (1)](https://blog.sparkfuneducation.com/author/celeste-moreno)
- [Samantha Nagle (1)](https://blog.sparkfuneducation.com/author/samantha-nagle)
- [Pearce Melcher (1)](https://blog.sparkfuneducation.com/author/pearce-melcher)

All Authors

### Recent Posts

### Submit Your Idea

[![SparkFun Education](https://www.sparkfuneducation.com/img/logo.png)](http://www.sparkfuneducation.com/index.html)

#### Other Resources

- [Contact Us](http://www.sparkfuneducation.com/contact-us.html)
- [About SparkFun](http://www.sparkfun.com)
- [FAQs](https://www.sparkfun.com/static/faq)

- [Customer Service](https://www.sparkfun.com/support)
- [Shipping](https://www.sparkfun.com/support)
- [Terms and Conditions](https://www.sparkfun.com/terms)

#### Sign Up for Newsletter

© Copyright 2016. All Rights Reserved.