DenScript Uno Kit Lesson 3: Using a button

Wiring

So far, so good! You have downloaded the software, become familiar with the different parts of the DenScript Uno Kit, and have written your first program! It is time now to using some input devices, and we will start with the easiest, the Tactile (Push Button) Module. Using a digital cable (the one that is black, red, white), connect the Tactile Module to port D5. Make sure you match all the colours on the cable and the connections properly.

Programming

The program for this lesson is very simple. Copy this code out and we will go through it.

First, we declare two variables, one called ‘button’, which we assign the value of ‘5’, and one called ‘led’, which we assign the value of ’13’.

In the ‘setup()’ function we set led as an output, and we set button as an input.

Finally, in the ‘loop()’ function, we want to set the value of the button to the led. What this actually means, is whenever the button is pressed, it is ‘HIGH’, and this will make the LED ‘HIGH’, which means on. When the button is not pressed, the value will be ‘LOW’, which is the same as off.

Once you have written this code out, upload it to your DenScript Uno. If you cannot remember how to do this, check back at the last tutorial.

Troubleshooting

If you are unable to upload your program, make sure the DenScript Uno has its power select jumper set to ‘VUSB’. If this is correct LED3 will be lit.

If there are issues selecting the DenScript Uno as the Serial Port in the Arduino IDE, it may be because your computer will need time to detect the DenScript Uno and set it up for first use.

All DenScript products have been tested before being shipped and any defunct units would be withheld. Therefore, we can not take responsibility if you break your unit.