In your starter kit, you received a breadboard. (Pictured right). This breadboard has 2 long horizontal lines along the top and Bottom of it, and then a series of holes throughout the middle. The midsection is connected vertically, with a break in the Middle as shown on the right of the image. The top and bottom Are connected horizontally and are for power distribution. Feel free to google the breadboard for more information!
Before we begin downloading and installing your Arduino, let me begin by talking about the software we will be using. IDE (Integrated Development Environment) is the software we will use to program the Arduino. It translates the code we write into the commands the Arduino expects. It also includes a serial monitor, serial logger and other useful tools and examples. We will be making good use of the Serial Monitor in this guide. Remember, any text you see in the serial monitor was made and sent through the USB cable FROM the Arduino to the computer. This guide is an introduction to the Arduino, it covers most of the components and modules you will find in your starter kit, and includes the code needed to get them all working. You are free to use and modify the code in your own projects, so you have a solid starting point. If you decide to expand your collection of modules later, be sure to shop with Aus Electronics Direct in order to get a guide like this for each additional component!
First, we must download the latest version of the Arduino IDE. Please navigate to the following URL:
Follow the steps below to download and install the software and drivers for your Arduino Prototyping Board:
Alternate Code:
In addition to the above code, I am including this additional code for you to try. Open the Serial Monitor like we did in the first project and you will be able to watch as the PWM values drop and the LED gets dimmer, and as they rise it gets brighter.
Try it out:
You should see numbers in the Serial Monitor window that increase as more light hits the sensor, and decrease as less light hits it. If you cover it completely you will see a 0;
What is your baseline? Consider the average reading when you allow the natural light of the room to hit the sensor. How large is the variance? If the minimum number was 10 and the maximum was 15, you would have a variance of 5 and an average baseline of 12. This sort of information is useful when designing code to do certain things...establish levels and have things happen when sensor readings drop below or rise above certain levels...In this case you could make a night light, that turns on when the room darkens, and off again when it is bright enough!
Expected outcome:
You will interface a flame sensor to the Arduino. This sensor is specially designed to isolate specific bands in the IR and UV wavelengths and looks for unique patterns in flames for an extremely accurate reading.
Note: If you get no reading when igniting a flame near the sensor, try reversing it. It is a polar device and needs to be in the correct way. It will not be damaged in this circuit if it is placed backwards.
You will learn to interface with the simple tilt sensor. This sensor is essentially a steel bearing in a tube. The leads go inside, and when the bearing is at the bottom of the can it completes the circuit. When the bearing rolls up the can the circuit is broken.
Note: the image is slightly different to the module you got, however it is wired the same. The LED should be towards you. It will be quite bright. I recommend a piece of paper or tissue over the lens.
Try it out:
The RGB LED should now cycle through random colors, every half a second the color should change. The LED is quite bright, I found it much easier to look at once I had placed a small piece of printer paper over the top of it, it also helps mix the colors better.
Expected outcome:
You will be able to take user input and process it. You might use this as an input for sensitivity, volume, intensity, or even as an analog input for a game controller or similar.
Try it out:
What we have done here is create a function for each character that we will display. In this case I have included the full HEX range. Perhaps you can merge this and the IR remote project, to have this display read off the code captured from the remotes.
You could of course create more functions for the rest of the alphabet. In my next project book I will rewrite this code so instead of specifying a function for each character, we will instead call a function with the string we want to display as a parameter like so:
displayString("String");
The displayString function will then work out the individual characters in the string and light them in order on the display with a configurable delay. It will also support the full stop which Right now I have not added.
To add more characters try setting all the pins to LOW except one (making sure to call the function you are modifying in the loop()). This will illuminate one section of the display. Once you have done this for each section and written down which pin corresponds to which segment you can create any shape possible as I have done :).
Expected outcome:
You will be able to use a passive buzzer, which is essentially a small speaker. You cannot just apply 5V to this as it will only move the cone in one direction. We can however use the PWM function to drive the coil both ways and emit steady tones. The example code below will play random pitched sounds through the speaker.
Try it out:
Once you run the code you should hear random sounds at random pitches. You could use this module to play a fixed pitch sound to signify button presses, errors or similar status feedback. In concert with an RGB LED this is all the notification you would need.
Expected outcome:
You will be able to use an active buzzer, it differs from the passive buzzer in the last project as all we have to do it provide a 5V connection to it to produce sound, it has its own circuit inside to drive the speaker. We can still supply PWM to modulate the pitch, although it is not necessary in this case.
Try it out:
Notice the buzzer creates a clear sound by simply applying power to it. If we used this same sketch on the passive speaker we would hear a very tiny blip and then nothing at all.
Note: Make sure the flat side is facing you, as seen in the image, and all connections are as shown. This component is polar and will heat up and degrade in sensitivity the longer it is left connected backwards.
Try it out:
The formula used to convert to temperature was derived from the data sheet. In this case we have the following elements:
5.0 is the voltage we are inputting.
100 is the multiplier to convert from mV to V
1024 is the maximum resolution of the analog input on the arduino.
Essentially we know from the data sheet that 10mV = 1 degree, which means if we convert and clean the reading using the above formula, we get the temperature in Degrees Celsius -/+ half a degree.
Using the knowledge I have imparted upon you, do you think you can combine any of the projects we have performed in order to make something new?
You could use an RGB LED to change colors depending on the temperature range...