Solved: Can't get Arduino Nano to work

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi - just bought a handful of Nano 3.0 boards, thought I'd try a blinker program.  I'm running AS7 on Windows 7.  I can't make the built-in LED to blink!  I tried the Arduino IDE, got it to work straightaway...  In desperation I'm just banging the entire port to get something to work.  What stupidity am I stuck in? thanks, paul

/*
 * Nano_Blinky.c
 *
 * Created: 2/24/2017 7:47:57 PM
 * Author : paul
 */ 

#define F_CPU 16000000UL
#include <avr/io.h>
#include <util/delay.h>
#define BLINK_DELAY_MS 1000

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

	while(1) {
		/* set entire port high to turn led on */

		PORTB |= 0xFF;
		_delay_ms(BLINK_DELAY_MS);

		/* set entire port low to turn led off */
		PORTB &= 0x00;
		_delay_ms(BLINK_DELAY_MS);
	}
}

 

Last Edited: Sun. Feb 26, 2017 - 12:19 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I built (using AS6.2 & Windows 7x64)) your program  listed above and downloaded the hex file

to a Chinese nano clone using avrdude and the built-in nano bootloader.

 

The LED blinked 1 second on and 1 second off - as expected.

 

How are you downloading the hex file to the nano?

Are you sure you are downloading the correct hex file?

 

Edit:

  Attached file Test_Nano_Blink_Led.hex.

 

 

Attachment(s): 

Last Edited: Sat. Feb 25, 2017 - 04:23 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Chuck99 is spot on - AS7 is acting up on me and loading the wrong hex file.  I'm using the Atmel ICE programmer, but somehow AS7 is picking the wrong hex file - thanks Chuck! paul

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Somehow I have "broken" AS7 - when I Build, it's not generating .hex or .elf files as it used to, very odd

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Got it - I'd inadvertently picked "Library Project" instead of executable, set it up right and it worked fine - thanks Chuck99