Programming my Board

  • This week’s assignment was to read a microcontroller Data Sheet and program your board to do something, with as many different programming language and programming environments as possible.

  • So starting off I read the data sheet briefly and then went through many pages from students last year, that got me sort of on the right track since I had never done this before. Yet I ran into a lot of trouble and debuggin took many trials and errors.

  • I used arduino IDE to write the program and used my fabISP as a programmer.

  • I followed the tutorial from high-low tech on how to set up arduino IDE for loading a program on the attiny.

  • In short, you copy the given link from the site, go the file>preferences> and paste it to “additional boards manager URLs”

  • Then go to tools>boards>boards manager and scroll down to the bottom where you should find attiny, click on the box and click install.

  • Next go to tools>boards> and down at the bottom should attiny be listed

  • In the tools section it should list:

    • Board: ATtiny
    • Processor: ATtiny44
    • Clock: 20Mhz (external)
    • (Skip port)
    • Programmer: USBtinyISP (Choose this if you are using the FabISP)
  • Now when thats done you install an FabISP driver, I found one on the adafruit site.

  • Now you connect the programmer(FabISP) to your board and plug them BOTH to your computer. Go to tools>Burn bootloader, you only need to do this once per board.

  • If you are prompted with an error message then something is wrong. “Couldn’t find USBtiny” could be that the FabISP driver wasn’t correctly installed. If you see no error message then congratulations.

  • Now, you can use the example programs that come with arduino to test the board, for example File>Examples>Basics>blink. To make the program work with the Attiny you need to change the pin numbers in arduino programs for they do not correspond to the same pins on the ATtiny. Here's a diagram I screenshoted from one of last year's student

  • Here's the code I used on my board.

  • 
     /*
     Fade
     */
    
    int led = 7;           // the PWM pin the LED is attached to
    int brightness = 0;    // how bright the LED is
    int fadeAmount = 10;    // how many points to fade the LED by
    
    
    void setup() {
      // declare pin 9 to be an output:
      pinMode(led, OUTPUT);
    }
    
    
    void loop() {
      // set the brightness of pin 9:
      analogWrite(led, brightness);
    
      // Brightness loop:
      brightness = brightness + fadeAmount;
    
      // reverse:
      if (brightness == 0 || brightness == 255) {
        fadeAmount = -fadeAmount ;
      }
      //  milliseconds
      delay(30);
    }
                                
  • Here’s the result, the LED fades slowly.

  • One problem that caused me a lot of time and frustration was that my board was not getting the bootloader correctly. The major of the problem was I didn’t know if it was the board causing this or if arduino IDE wasn’t set up correctly. I tried plugging it into the AvrISP mkII and it started blinking orange light, meaning there was something wrong. I spent a lot of time looking at the soldering. But after a while I took a closer look on the schematic of the board I designed and noticed that one of the FCI pins wasn’t connected to anything.

  • So I bridged it to connect to the pull-up resistor using a wire. Problem solved! So the boards design is a little messed up.

  • I included programming in my final project.