Inventors Kit for Arduino - Exp 1 Digital Inputs & Outputs

Experiment 1 from the Inventors Kit for Arduino, in which we explore Digital Inputs & Outputs. Included in this resource are code downloads, a description of the experiment and also a video walkthrough. This resource provides additional help and is not meant to replace the documentation that ships with the kit. Arduino Inventors Kit Exp 1 Digital Inputs & Outputs Arduino is an open-source code-able electronics platform, which has been designed for anyone making interactive projects. The boards can process inputs from many sensors, and also control outputs such as LEDs and motors. The Arduino is controlled by the code with which it is programmed. This code is written in the Arduino programming language, using the Integrated Development Environment (IDE). Once complete the code is easily then programmed on to the Arduino board using a simple USB lead.  

 

Inventors Kit for Arduino Exp 1 Digital Inputs & Outputs: 

This simple first experiment we use a button to control the state of the LED built into the board. The aims of this experiment are:

  • Use a switch as an input.
  • To use a Boolean variable.
  • Use the ‘if’ command to then determine the state of the switch.
  • To use the on-board LED as an output to indicate the state of the switch.
  • Then, compile and upload a sketch to the Arduino board.

 

Video Walkthrough:

 

Exp 1 Code:

Either open a new Sketch then create the following code by typing in the editor window, or, copy and paste it straight into the editor

/*
  Kitronik Inventors Kit Exp 1.

  Turns an LED on  and off in response to a press on the button that is connected to Pin 2.

  Most Arduinos have an on-board LED you can control.
  LED_BUILTIN is set to the correct LED pin independent of which board is used.

  The switch is connected from the 5V output header to input pin 2.

  */

const int SwitchInputPin = 2; //Define a human readable name for the input the switch is connected to.

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin  for the LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
  // and similarly the switch pin as an input
  pinMode (SwitchInputPin, INPUT);
}


//A variable to hold the value of the button - HIGH (TRUE) or LOW(FALSE)
boolean buttonValue;

// the loop function runs forever, reading the button value and acting on it to trun on or off the LED

void loop() 
{
  //First read the state of the button.
  buttonValue = digitalRead(SwitchInputPin);
  //Now decide what to do.
  if(buttonValue)
  {
    digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  }
  else
  {
    digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  }
}

 

Inventors Kit Extra Resources:

Each of the ten experiments has been designed to ease you into coding and also physical computing for the Arduino. The experiments have been chosen to cover the key concepts of physical computing and they also increase in difficulty as you progress. If you are new to this, even the least complex examples can be quite challenging. With this in mind, we created walkthrough videos for each of the experiments. Our presenter talks you through the circuit in a way that backs up the information given in the booklet but in a style that some might find easier to absorb. As well as having a video walkthrough, each page also contains the code. Although it is always good to tackle the code yourself, it can be handy for testing your circuit. The code has been heavily commented as an extra learning resource. To get the most out of the experiment, once you've tested your circuit have a go at coding the experiment from scratch. Follow the links in the table below:  

Exp No#. Experiment Name.
1
Digital Inputs & Outputs.
2
Light Sensor & Analog Inputs.
3
Dimming an LED using a potentiometer.
4
Using a transistor to drive a motor.
5
Control a servo with a potentiometer.
6
Setting the tone with a piezo buzzer.
7
Using a seven segment display.
8
Exploring wind power.
9
Capacitor charge circuit.
10
Using an RGB LED.

Leave a comment

All comments are moderated before being published