You are viewing outdated content for BUG. If you have a BUG Y.T. edition or 2.0 series device, please visit our updated wiki: http://wiki.buglabs.net



Getting Started with Arduino for Bugduino

From BUG Wiki

Jump to: navigation, search

Contents

Programming the BUGduino Through the standard Arduino IDE

  • connect your sparkfun FTDI basic to your bugduino this way:

  • connect the FTDI to your computer trough an usb cable
  • orientate the bugduino like on the picture and turn the button to the right(else programming won't work)
  • install the Arduino IDE (refer to the arduino page for installation)
  • launch the Arduino IDE
  • select your USB serial port trough tools->serial port
  • select the "Arduino Duemillanove or Nano w/ ATmega 328" in tools->board
  • go to file->example->basics->blink
  • press the send button which looks like that
  • connect a led between pb5 and ground, if you're unsure how to wire it, try both ways.

  • watch the led blinking

Notes

Note that what we first attempted works, although some things won't work without attaching the bugduino to a bug device, like the 5v output

Programming in C for the Bugduino

Copy that program into blink.c

#include <avr/io.h>
#include <util/delay.h>

#define DELAY 5000

int main (void)
{
  /* set PORTB for output*/
  DDRB = 0xFF;

  while (1)
    {
      /* set PORTB.6 high */
      PORTB = 0xFF; 

      _delay_ms(DELAY); 

      /* set PORTB.6 low */
      PORTB = 0x00; 

      _delay_ms(DELAY);
    }

  return 1;
}

Run that:

avr-gcc -DF_CPU=16000000UL -mmcu=atmega328p -o blink.out  blink.c
avr-objcopy -O ihex -R .eeprom blink.out blink.hex
sudo avrdude -V -F -c stk500v1 -p atmega328p -b 57600 -P /dev/ttyUSB0 -U flash:w:blink.hex

And remember to orientate the bugduino like on the picture and to turn the button to the right(else programming won't work) before attempting to program the bugdiono

Examples of other programs

References