Skip to content

Instantly share code, notes, and snippets.

@technovusSFU
Created October 21, 2017 16:23
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save technovusSFU/e26881a5242d57d06180c64d6014534a to your computer and use it in GitHub Desktop.
Technovus Swarmbots Workshop 1

Microcontroller Basics

Lighting up an LED

Items Required:

  1. Arduino board
  2. LED
  3. 220 Ω resistor

Circuit

circuit image

Code

const int led_pin = 8; 

void setup()
{
  pinMode(led_pin, OUTPUT);
}

void loop()
{
  digitalWrite(led_pin, HIGH);
  delay(1000);
  digitalWrite(led_pin, LOW);
  delay(1000);
}

Bare microcontroller on breadboard

Burning the bootloader:

  1. Download this hardware configuration archive: breadboard-1-6-x.zip
  2. Create a "hardware" sub-folder in your Arduino sketchbook folder (whose location you can find in the Arduino preferences dialog).
  3. Move the breadboard folder from the zip archive to the "hardware" folder of your Arduino sketchbook.
  4. Restart the Arduino software.
  5. You should see "ATmega328 on a breadboard (8 MHz internal clock)" in the Tools > Board menu.
  6. Wire up the Arduino board and microcontroller as shown in the EAGLE schematic. bootloader schematic image
  7. Select "ATmega328 on a breadboard (8 MHz internal clock)" as the board type using Tools > Board.
  8. Select "Arduino as ISP" from Tools > Programmer
  9. Run Tools > Burn Bootloader
  10. After burning the bootloader, you can remove the jumper wires connected to pins 10, 11, 12, and 13 of the Arduino board.

Uploading sketches to microcontroller on breadboard

  1. Wire up the Arduino board and microcontroller as shown in the next EAGLE schematic. upload sketch schematic image
  2. Select "ATmega328 on a breadboard (8 MHz internal clock)" as the board type using Tools > Board.
  3. Upload the sketch as usual (Ctrl+U, or Sketch > Upload, or the right arrow button).

Lighting an LED using microcontroller on breadboard

  1. Before uploading the LED blinking sketch we wrote earlier, change led_pin to 9. Then upload the sketch to the microcontroller on the breadboard.
  2. Wire up the Arduino board and microcontroller as shown in the next EAGLE schematic. LED schematic image
  3. If the correct sketch was uploaded to the microcontroller, you should see the LED blinking.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment