Arduino Workshop 1

These are the circuits we build in the first session of the Arduino workshop Rise of the Microcontrollers.

Simple LED Circuit

For your first circuit, we’ll use the Arduino Uno just as a power source – as if it were a battery.

  • Components
    • Two wires
    • 220 ohm resistor (if you have the Arduino kit from CS4ALL, the 220 ohm resistors have a blue or black stripe on the paper strip they are attached to)
    • LED
  • Connections
    • Wire from the 5V pin on the Arduino Uno to a row on the breadboard (red wire in the photo)
    • Resistor from that row on the breadboard to another row
    • LED
      • positive lead (the longer one) in that row of the breadboard
      • negative lead (the shorter one) in another row
    • Wire from that row to any of the GND pins on the Arduino Uno
  • Plug the Arduino Uno into your computer and the LED should glow
  • If the LED doesn’t glow
    • Check your connections
      • The leads of the different components should not be touching. All connections should be made through the breadboard rows.
      • The leads and wires should be fully inserted into the holes of the breadboard.
    • Make sure the LED is in the right way. The longer lead is the positive side and should be in the same row as one of the leads of the resistor.
    • Try a different LED in case the one you’re using is bad. If the new LED lights up, you can probably throw the other one away.
  • If the LED glows but isn’t very bright
    • You may be using a resistor with a higher value. With a 220 ohm resistor the LED will glow brightly. If you instead use a 1K ohm or 10K ohm resistor, the LED light will be very hard to see.

 

2016-10-09-11_41_59-obs32

circuit-01_bb

Arduino-Controlled LED Circuit

If you built the previous circuit, this one is really easy! First unplug the Arduino from your computer. Now move the end of the red wire from the 5V pin to pin 13. Plug the Arduino Uno into your computer and the LED should start blinking slowly. You may notice that there is a much smaller LED on the Arduino Uno itself that blinks the same way. These LEDs are blinking because all Arduino Unos are programmed at the factory with a simple program called Blink. After you’ve made the circuit, it’s time to do your first program! Look below the circuit images for more on that.

2016-10-09-11_41_25-obs32

circuit-02_bb

Keep the Arduino Uno plugged into your computer and run the Arduino IDE on your computer. (Instructions for installing Arduino IDE are on the main Rise of the Microcontrollers page.)

Open the Tools menu and then the Port submenu. On the list of serial ports (yours may look different than the screenshot), find the one that has (Arduino/Genuino Uno) after it and select it.

2016-10-12-19_57_44-blink-_-arduino-1-6-12

Open the File menu and go to Examples->01.Basics->Blink. That will open the code you see below.

2016-10-12-17_15_28-blink-_-arduino-1-6-12

 

Look for the lines of code that say “delay(1000);”. Those make the program wait for 1000 milliseconds. A millisecond is one thousandth of a second, so there are 1000 milliseconds in one second. Therefore, “delay(1000);” makes the program wait for one second. These two lines are what controls the speed at which the LED blinks. Try changing one or both of the numbers and then click the arrow button at the top of the window. Once the program uploads, the LED will start blinking at a different rate. Now try some different numbers and upload the code again. Congratulations! You’ve done your first coding in Arduino!

2016-10-12-19_44_01-blink-_-arduino-1-6-12

Photoresistor Circuit

Unplug the Arduino from your computer. For this circuit, we’re going to add a sensor. A sensor allows us to tell something about the world.

  • Components
    • Three wires
    • 10K ohm resistor (if you have the Arduino kit from CS4ALL, the 10K ohm resistors have a green stripe on the paper strip they are attached to)
    • Photoresistor
  • Connections
    • Wire from the 5V pin on the Arduino Uno to a row on the breadboard (red wire in the photo)
    • Photoresistor from that row on the breadboard to another row
    • Resistor from that row to another row
    • Wire from that row to any of the GND pins on the Arduino Uno (black wire in the photo)
    • Wire from the row that is connected to both the photoresistor and the resistor to pin A0 on the Arduino Uno (blue wire in the photo)

 

  • 2016-10-09-11_30_28-obs32

circuit-03-photoresistor_bb

  • In the Arduino IDE on your computer, open another example sketch called AnalogInput (File->Examples->03.Analog->AnalogInput)

2016-10-19-19_58_03-gammon_flash_and_fade-_-arduino-1-6-12

  • Plug the Arduino Uno into your computer
  • In the Arduino IDE, click the Upload (arrow) button
  • The LED will be blinking again. Put your finger on the top of the photoresistor to block light from hitting it. The LED should start blinking a little faster. Remove your finger and shine a light on the photoresistor and the LED should blink more slowly.